:root {
  --bg: #f3efe5;
  --panel: #fffaf0;
  --ink: #14213d;
  --muted: #5b6476;
  --line: #d7cfbe;
  --accent: #d95d39;
  --accent-soft: #f4c4b7;
  --ready: #1b7f5a;
  --ready-soft: #d7f0e6;
  --empty: #c27a0e;
  --empty-soft: #f8e7c1;
  --error: #b42318;
  --error-soft: #f8d5d2;
  --shadow: 0 16px 40px rgba(20, 33, 61, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(217, 93, 57, 0.18), transparent 24rem),
    radial-gradient(circle at right, rgba(20, 33, 61, 0.1), transparent 30rem),
    var(--bg);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
}

.app-shell {
  max-width: 1500px;
  margin: 0 auto;
  padding: 2rem;
}

.app-nav {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.app-nav-link {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.app-nav-link:hover,
.app-nav-link.active {
  border-color: rgba(217, 93, 57, 0.6);
  box-shadow: 0 10px 20px rgba(20, 33, 61, 0.08);
  transform: translateY(-1px);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  align-items: end;
  margin-bottom: 1.5rem;
}

.hero h1,
.detail-header h2 {
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 4.4rem);
  line-height: 0.95;
}

.eyebrow {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--accent);
}

.lede {
  max-width: 52rem;
  color: var(--muted);
  font-size: 1rem;
}

.lede.small {
  margin-top: 0.5rem;
}

.legend {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.layout {
  display: grid;
  grid-template-columns: minmax(18rem, 26rem) minmax(0, 1fr);
  gap: 1.25rem;
}

.panel {
  background: rgba(255, 250, 240, 0.9);
  border: 1px solid rgba(215, 207, 190, 0.8);
  border-radius: 1.5rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.sidebar {
  padding: 1rem;
}

.detail {
  padding: 1.25rem;
  min-height: 70vh;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.panel-head h2 {
  margin: 0;
}

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

.filters,
.detail-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.filters {
  margin-bottom: 1rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.checkbox-label {
  align-content: end;
}

.checkbox-label input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0.1rem 0 0;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  background: #fff;
  color: var(--ink);
  padding: 0.75rem 0.9rem;
  font: inherit;
}

input:focus,
select:focus {
  outline: 2px solid rgba(217, 93, 57, 0.22);
  border-color: var(--accent);
}

.swimmer-list {
  display: grid;
  gap: 0.75rem;
  max-height: calc(100vh - 18rem);
  overflow: auto;
  padding-right: 0.2rem;
}

.swimmer-card {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.72);
  padding: 0.95rem;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.swimmer-card:hover,
.swimmer-card.active {
  transform: translateY(-1px);
  border-color: rgba(217, 93, 57, 0.6);
  box-shadow: 0 12px 22px rgba(20, 33, 61, 0.08);
}

.swimmer-card h3 {
  margin: 0 0 0.3rem;
  font-size: 1.05rem;
}

.swimmer-meta,
.swimmer-stats {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.86rem;
}

.status-pill,
.course-pill,
.flag-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.status-ready {
  color: var(--ready);
  background: var(--ready-soft);
}

.standard-b { color: #8d6e63; background: #f1e4dd; }
.standard-bb { color: #7f5539; background: #efe0d3; }
.standard-a { color: #2f855a; background: #daf1e3; }
.standard-aa { color: #2b6cb0; background: #d8e8fb; }
.standard-aaa { color: #6b46c1; background: #eadffc; }
.standard-aaaa { color: #b42318; background: #f8d5d2; }
.standard-none { color: var(--muted); background: rgba(20, 33, 61, 0.08); }
.cutoff-regional { color: #6e4f1f; background: #f6ead1; font-style: italic; }
.cutoff-age-group { color: #624600; background: #fff1a8; font-weight: 800; }

.standard-badge-stack {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(6rem, 1fr));
  gap: 0.75rem;
}

.summary-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.85rem 1rem;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.summary-card strong {
  font-size: 1.5rem;
}

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

.detail-toolbar {
  margin-bottom: 1rem;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.8);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.8rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid rgba(215, 207, 190, 0.75);
  vertical-align: top;
}

thead th {
  position: sticky;
  top: 0;
  background: #f8f3e8;
  z-index: 1;
}

tbody tr.standard-b { background: rgba(141, 110, 99, 0.1); }
tbody tr.standard-bb { background: rgba(127, 85, 57, 0.08); }
tbody tr.standard-a { background: rgba(47, 133, 90, 0.1); }
tbody tr.standard-aa { background: rgba(43, 108, 176, 0.1); }
tbody tr.standard-aaa { background: rgba(107, 70, 193, 0.1); }
tbody tr.standard-aaaa { background: rgba(180, 35, 24, 0.12); }
tbody tr.standard-none { background: rgba(20, 33, 61, 0.04); }

.callout {
  border-radius: 1rem;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  background: var(--error-soft);
  color: var(--error);
  border: 1px solid rgba(180, 35, 24, 0.2);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 50vh;
  text-align: center;
}

.hidden {
  display: none !important;
}

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

  .hero,
  .detail-header {
    grid-template-columns: 1fr;
    display: grid;
  }

  .filters,
  .detail-toolbar,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .swimmer-list {
    max-height: 28rem;
  }
}
