/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: #333;
  background:
    linear-gradient(180deg, rgba(27,128,141,0.10), rgba(247,250,250,0) 260px),
    #f7fafa;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
  --teal:       #1b808d;
  --teal-light: #d8f3f6;
  --teal-dark:  #12737b;
  --cyan:       #26c0d5;
  --navy:       #1b1e34;
  --gray-dark:  #32373c;
  --gray-mid:   #606060;
  --gray-light: #e5eeee;
  --ink:        #1b1e34;
  --mint:       #eff8f9;
  --line:       #d4e4e7;
  --gold:       #fcb900;
  --danger:     #cf2e2e;
  --white:      #fff;
  --radius:     6px;
  --shadow:     0 2px 8px rgba(0,0,0,0.10);
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--navy);
  color: var(--white);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.site-header__inner { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.site-header__logo  { height: 48px; width: auto; object-fit: contain; }
.site-header__brand { font-size: 1.1rem; font-weight: 700; color: var(--white); }
.site-header__dates { font-size: 0.8rem; color: #bfe8ee; }

/* ── Nav ──────────────────────────────────────────────────────────────────── */
.site-nav { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.site-nav__link {
  color: #d8f3f6;
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  transition: background 0.15s;
}
.site-nav__link:hover        { background: rgba(255,255,255,0.12); }
.site-nav__link--admin       { color: var(--gold); }

/* ── Main ─────────────────────────────────────────────────────────────────── */
.site-main {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}
h2 { color: var(--gray-dark); margin-bottom: 1rem; font-size: 1.6rem; }
h3 { color: var(--gray-dark); margin-bottom: 0.75rem; font-size: 1.15rem; }
.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.2rem;
}
.page-heading h2 { margin-bottom: 0.25rem; }
.page-heading__subtext {
  color: #637174;
  font-size: 0.95rem;
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.section-heading h3 { margin-bottom: 0; }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--navy);
  color: #d8f3f6;
  text-align: center;
  padding: 0.75rem;
  font-size: 0.8rem;
}

/* ── Flash / Banners ──────────────────────────────────────────────────────── */
.flash-success {
  background: #d4edda; color: #155724; border: 1px solid #c3e6cb;
  padding: 0.75rem 1.5rem; text-align: center; font-weight: 500;
}
.challenge-banner {
  padding: 0.75rem 1rem; border-radius: var(--radius);
  margin-bottom: 1rem; font-weight: 500;
}
.challenge-banner--pending { background: #fff3cd; color: #856404; border: 1px solid #ffc107; }
.challenge-banner--ended   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block; font-weight: 700; margin-bottom: 0.4rem;
  color: var(--ink); font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; max-width: 100%;
  padding: 0.72rem 0.8rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 1rem; background: var(--white);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.form-group input:focus,
.form-group select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 4px rgba(27,128,141,0.14); }
.form-group fieldset,
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.form-disabled { opacity: 0.6; pointer-events: none; }
.radio-group { display: flex; gap: 1.5rem; align-items: center; margin-top: 0.25rem; }
.radio-group label {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 0;
}
.radio-group input[type="radio"] {
  width: auto;
  max-width: none;
  padding: 0;
  border: 0;
  box-shadow: none;
}
.radio-group--segmented {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: #eef3f2;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.radio-group--segmented label {
  position: relative;
  cursor: pointer;
}
.radio-group--segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.radio-group--segmented span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.15rem;
  min-width: 6rem;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  color: #526164;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.radio-group--segmented input:checked + span {
  background: var(--white);
  color: var(--teal-dark);
  box-shadow: 0 1px 3px rgba(37,48,51,0.14);
}

/* ── Log Activity ─────────────────────────────────────────────────────────── */
.activity-panel {
  background: rgba(255,255,255,0.94);
  border: 1px solid rgba(216,227,225,0.95);
  border-top: 4px solid var(--teal);
  border-radius: var(--radius);
  box-shadow: 0 16px 36px rgba(27,30,52,0.10);
  padding: 1.2rem;
}
.activity-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.15rem;
}
.activity-form-grid .form-group { margin-bottom: 0; }
.activity-panel__actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.btn-wide { min-width: 11rem; text-align: center; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block; padding: 0.64rem 1.25rem;
  border: none; border-radius: var(--radius);
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: background 0.15s, opacity 0.15s, transform 0.15s, box-shadow 0.15s;
}
.btn-primary   { background: var(--teal); color: var(--white); box-shadow: 0 8px 18px rgba(18,115,123,0.24); }
.btn-primary:hover   { background: var(--teal-dark); transform: translateY(-1px); }
.btn-secondary { background: var(--gray-dark); color: var(--white); }
.btn-secondary:hover { opacity: 0.85; }
.btn-outline   { background: transparent; color: var(--teal); border: 2px solid var(--teal); }
.btn-outline:hover   { background: var(--teal); color: var(--white); }
.btn-danger    { background: var(--danger); color: var(--white); }
.btn-danger:hover    { opacity: 0.85; }
.btn-sm        { padding: 0.3rem 0.7rem; font-size: 0.82rem; }

/* ── Errors ───────────────────────────────────────────────────────────────── */
.error-message { color: var(--danger); background: #fdf0f0; border: 1px solid #f5c6cb; padding: 0.6rem 0.9rem; border-radius: var(--radius); margin-bottom: 1rem; }
.error-list    { color: var(--danger); background: #fdf0f0; border: 1px solid #f5c6cb; padding: 0.6rem 0.9rem 0.6rem 1.5rem; border-radius: var(--radius); margin-bottom: 1rem; }
.error-list li { margin-bottom: 0.2rem; }

/* ── Motivational message ─────────────────────────────────────────────────── */
.motivational-msg {
  margin-top: 1rem;
  font-size: 0.92rem;
  color: var(--teal-dark);
  min-height: 1.2em;
  font-weight: 600;
}
.motivational-msg:not(:empty) {
  background: var(--mint);
  border: 1px solid var(--teal-light);
  border-radius: var(--radius);
  padding: 0.65rem 0.8rem;
}

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; margin-top: 0.5rem; }
.table-wrapper--polished {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; background: var(--white); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table-wrapper--polished table { box-shadow: none; }
thead { background: var(--gray-dark); color: var(--white); }
th, td { padding: 0.65rem 0.9rem; text-align: left; font-size: 0.9rem; }
tbody tr:nth-child(even) { background: #f9f9f9; }
tbody tr:hover { background: #f0fafa; }
.activity-history-table th,
.activity-history-table td { padding: 0.78rem 0.95rem; }
.activity-history-table tbody tr:nth-child(even) { background: #fbfdfd; }

/* ── Leaderboard ──────────────────────────────────────────────────────────── */
.leaderboard-toggle { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; }
.leaderboard-row--current { background: #e6f7f6 !important; font-weight: 600; }
.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 99px; font-size: 0.85rem; font-weight: 700; }
.badge--gold   { background: #fff3cd; color: #856404; }
.badge--silver { background: #e8e8e8; color: #555; }
.badge--bronze { background: #fde8d8; color: #7a3b1e; }
.you-badge { background: var(--teal); color: var(--white); font-size: 0.7rem; padding: 0.1rem 0.4rem; border-radius: 99px; vertical-align: middle; margin-left: 0.3rem; }

/* ── Category Leader Cards ────────────────────────────────────────────────── */
.category-leaders { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
.category-card {
  background: var(--white); border-radius: var(--radius); padding: 0.9rem 1rem;
  box-shadow: var(--shadow); border-top: 3px solid var(--teal); text-align: center;
}
.category-card__icon  { font-size: 1.6rem; margin-bottom: 0.3rem; }
.category-card__label { font-size: 0.75rem; color: var(--gray-mid); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.25rem; }
.category-card__name  { font-weight: 600; font-size: 0.95rem; color: var(--gray-dark); }
.category-card__total { font-weight: 400; font-size: 0.8rem; color: var(--gray-mid); }

/* ── Road Trip Map ────────────────────────────────────────────────────────── */
.road-trip-map { height: 320px; border-radius: var(--radius); margin-bottom: 1.25rem; box-shadow: var(--shadow); border: 1px solid var(--gray-light); }
.map-marker {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--gray-dark); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; border: 2px solid var(--white);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.map-marker--current { background: var(--teal); border: 2px solid var(--gold); }
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background: rgba(27,128,141,0.22);
}
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background: var(--teal);
  color: var(--white);
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(27,30,52,0.22);
}

/* ── Summary Cards ────────────────────────────────────────────────────────── */
.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
.summary-card {
  background: var(--white); border-radius: var(--radius); padding: 1rem;
  box-shadow: var(--shadow); text-align: center; border-top: 3px solid var(--teal);
}
.summary-card__value { font-size: 2rem; font-weight: 700; color: var(--teal); }
.summary-card__label { font-size: 0.8rem; color: var(--gray-mid); margin-top: 0.2rem; }

/* ── Week Selector ────────────────────────────────────────────────────────── */
.week-selector { margin-bottom: 1.25rem; display: flex; align-items: center; gap: 0.75rem; }
.week-selector label { font-weight: 600; color: var(--gray-dark); }
.week-selector select { padding: 0.4rem 0.6rem; border: 1px solid #ccc; border-radius: var(--radius); font-size: 0.9rem; }

/* ── Register CTA ─────────────────────────────────────────────────────────── */
.register-cta { background: #e6f7f6; border: 1px solid var(--teal-light); border-radius: var(--radius); padding: 0.75rem 1rem; margin-bottom: 1.25rem; }

/* ── Status badges ────────────────────────────────────────────────────────── */
.status-active      { color: #155724; background: #d4edda; padding: 0.15rem 0.5rem; border-radius: 99px; font-size: 0.8rem; font-weight: 600; }
.status-deactivated { color: #721c24; background: #f8d7da; padding: 0.15rem 0.5rem; border-radius: 99px; font-size: 0.8rem; font-weight: 600; }

/* ── Utilities ────────────────────────────────────────────────────────────── */
.text-muted { color: var(--gray-mid); font-size: 0.9rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .site-header { flex-direction: column; align-items: flex-start; }
  .site-nav    { width: 100%; }
  .site-main   { padding: 1rem 0.75rem; }
  .form-group input, .form-group select { max-width: 100%; }
  .page-heading { align-items: flex-start; margin-bottom: 1rem; }
  .page-heading__subtext { font-size: 0.88rem; }
  .activity-panel { padding: 0.95rem; }
  .activity-form-grid { grid-template-columns: 1fr; gap: 0.9rem; }
  .activity-panel__actions { justify-content: stretch; }
  .activity-panel__actions .btn { width: 100%; }
  .radio-group--segmented { display: flex; width: 100%; }
  .radio-group--segmented label { flex: 1; }
  .radio-group--segmented span { min-width: 0; width: 100%; }
  .road-trip-map { height: 220px; }
  h2 { font-size: 1.3rem; }
}
@media (min-width: 1400px) {
  .site-main { max-width: 1200px; }
}
