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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f4f4f4;
  color: #222;
  line-height: 1.5;
}

header {
  background: #e52329;
  color: #fff;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

header .logo { height: 56px; width: auto; }

header .logo-right { height: 56px; width: auto; }

header h1 { font-size: 1.4rem; font-weight: 600; }

nav {
  background: #2b863d;
  padding: 0.5rem 2rem;
  display: flex;
  gap: 1.5rem;
}

nav a { color: #fff; text-decoration: none; font-weight: 500; }
nav a:hover { text-decoration: underline; }

main { max-width: 1400px; margin: 1.5rem auto; padding: 0 1rem; }

section { background: #fff; border-radius: 6px; padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

h2 { font-size: 1.2rem; margin-bottom: 1rem; color: #e52329; }

/* Forms */
form { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

label { font-weight: 500; }

select, .search-input, button {
  padding: 0.45rem 0.75rem;
  font-size: 0.95rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}

select { min-width: 80px; }

.search-input { flex: 1; min-width: 200px; }

button {
  background: #2b863d;
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 500;
}

button:hover { background: #c83d40; }

/* Advanced search filters */
.advanced-filters {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: #f8fafc;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
}
.advanced-filters summary {
  cursor: pointer;
  font-weight: 500;
  color: #555;
  padding: 0.25rem 0;
}
.advanced-filters summary:hover { color: #222; }
.filter-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
.filter-row label { min-width: auto; white-space: nowrap; }
.year-input { width: 80px; padding: 0.35rem 0.5rem; font-size: 0.9rem; border: 1px solid #ccc; border-radius: 4px; }
.stage-input { width: 60px; padding: 0.35rem 0.5rem; font-size: 0.9rem; border: 1px solid #ccc; border-radius: 4px; }
.to-sep { color: #888; font-size: 0.85rem; }
.filter-row select { min-width: auto; padding: 0.35rem 0.5rem; font-size: 0.9rem; }
.filter-row input[type="text"] { padding: 0.35rem 0.5rem; font-size: 0.9rem; border: 1px solid #ccc; border-radius: 4px; width: 180px; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }

th, td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid #e0e0e0; white-space: nowrap; }

th { background: #eef3f8; font-weight: 600; color: #e52329; position: sticky; top: 0; }

tr:hover td { background: #f8fafc; }
tr.first-vets td { background: #fff9c4; }
tr.first-vets:hover td { background: #fff59d; }
tr.first-ladies td { background: #ffe0f0; }
tr.first-ladies:hover td { background: #f8b0d4; }
tr.first-business-house td { background: #d4edda; }
tr.first-business-house:hover td { background: #b8dfc6; }
tr.nre td { color: #999; font-style: italic; }
.nre-label { color: #999; font-style: italic; }

td.pos, td.time { font-variant-numeric: tabular-nums; }
td.pos { text-align: center; }
td.time { text-align: left; }

a { color: #2b863d; text-decoration: none; }
a:hover { text-decoration: underline; }

.count { margin-top: 0.75rem; font-size: 0.85rem; color: #666; }

.none { color: #888; font-style: italic; }
.footnote { margin-top: 0.75rem; font-size: 0.85rem; color: #888; }

.stage-info h2 { margin-bottom: 0.75rem; }

/* Runner search section on main page */
.stage-selector form { display: flex; align-items: center; gap: 0.75rem; }

.stage-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
  gap: 0.75rem;
}

.stage-nav a {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: #2b863d;
  color: #fff;
  border-radius: 4px;
  font-weight: 500;
  text-decoration: none;
}

.stage-nav a:hover { background: #c83d40; text-decoration: none; }

.stage-nav .next { margin-left: auto; }

/* Statistics page */
.stats-summary { max-width: 400px; }
.stats-summary th { text-align: left; background: none; padding-left: 0; }
.stats-summary td.stat-number { font-size: 1.4rem; font-weight: 600; color: #e52329; text-align: right; }

.stats-list { max-width: 600px; }
.stats-list.wide { max-width: 100%; }
.stats-list.appearances { max-width: 900px; }
.stats-list.appearances td:nth-child(3) { white-space: normal; }
.stats-list.with-clubs { max-width: 900px; }
.stats-list.with-clubs td:nth-child(3) { white-space: normal; }
.stats-list h3 { font-size: 1rem; margin-bottom: 0.75rem; color: #2b863d; }
.stats-list td:last-child { text-align: center; font-weight: 600; }
.stats-list td.num { text-align: center; font-weight: normal; }
.stats-list.wide td:nth-child(2) { white-space: normal; }

.team-appearances { max-width: 100%; }
.team-appearances td.years-list { white-space: normal; word-break: break-word; }

.flash-messages { margin-bottom: 1rem; }
.flash-message {
  padding: 0.75rem 1rem;
  margin: 0 0 0.5rem 0;
  border-radius: 4px;
  font-weight: 600;
}
.flash-success {
  background: #e8f5e9;
  border-left: 4px solid #2b863d;
  color: #1b5e20;
}
