:root {
  --brand: #FF851B;
  --brand-dark: #E5731A;
  --brand-tint: #FFF1E0;
  --navy: #1e3a8a;
  --navy-dark: #172554;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --success: #16a34a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; font-weight: 600; }
a:hover { color: var(--brand-dark); }

.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

/* Top bar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  position: sticky; top: 0; z-index: 100;
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; color: var(--navy); font-size: 18px;
  text-decoration: none;
}
.brand-mark {
  display: inline-block;
  width: 32px; height: 32px;
  border-radius: 8px;
  object-fit: cover;
}
.nav { display: flex; gap: 4px; }
.nav a {
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
}
.nav a:hover { background: var(--brand-tint); color: var(--brand-dark); }
.nav a.active { background: var(--brand-tint); color: var(--brand-dark); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--bg); }
.btn-primary {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { color: var(--danger); border-color: #fecaca; background: #fef2f2; }
.btn-danger:hover { background: #fee2e2; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.card h2 { margin: 0 0 6px; font-size: 18px; color: var(--navy); }
.card .muted { color: var(--muted); font-size: 14px; margin: 0; }

/* Layout helpers */
.stack > * + * { margin-top: 16px; }
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 700px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* Hero / login */
.hero {
  max-width: 480px;
  margin: 80px auto 40px;
  padding: 0 24px;
  text-align: center;
}
.hero .badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--brand);
  color: white;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-size: 11px;
  text-transform: uppercase;
}
.hero h1 {
  font-size: 44px;
  margin: 20px 0 10px;
  color: var(--navy);
  letter-spacing: -0.5px;
}
.hero .sub {
  color: var(--muted);
  font-size: 17px;
  margin: 0 0 32px;
}

/* Sign-in buttons */
.signin-stack { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.signin-btn {
  width: 100%;
  max-width: 320px;
  padding: 14px 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: background 0.15s;
}
.signin-btn:hover { background: var(--bg); }
.signin-btn svg { width: 18px; height: 18px; }
.signin-apple { background: black; color: white; border-color: black; }
.signin-apple:hover { background: #222; }

/* Section header */
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 32px 0 12px;
}
.section-title h2 {
  margin: 0;
  font-size: 22px;
  color: var(--navy);
}
.section-title a { font-size: 14px; }

/* Empty state */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}
.empty h3 { margin: 0 0 6px; color: var(--text); font-size: 16px; }

/* Tables */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data th,
table.data td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data thead th {
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--bg); cursor: pointer; }
table.data .row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
table.data .row-actions button {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 13px;
}
table.data .row-actions button:hover { background: var(--bg); color: var(--text); }
table.data .row-actions .danger:hover { background: #fef2f2; color: var(--danger); }

/* Badges */
.badge-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.badge-M { background: #dbeafe; color: #1e40af; }
.badge-F { background: #fce7f3; color: #9d174d; }
.badge-track { background: #fef3c7; color: #92400e; }
.badge-xc    { background: #dcfce7; color: #166534; }
.badge-training { background: #ede9fe; color: #5b21b6; }
.badge-race  { background: #fee2e2; color: #991b1b; }

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.toolbar .chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.chip.active { background: var(--navy); color: white; border-color: var(--navy); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: white;
  border-radius: 16px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  padding: 28px;
}
.modal h3 { margin: 0 0 16px; color: var(--navy); font-size: 20px; }
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

/* Forms */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--brand);
}
.field-row { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }

/* Footer */
footer {
  text-align: center;
  padding: 40px 24px;
  color: var(--muted);
  font-size: 13px;
}
