:root {
  /* Brand palette sampled from the Pickleplex hours dashboard */
  --orange: #ff6a13;
  --orange-dark: #d9560a;
  --orange-light: #ffece0;
  --navy: #2a0f52;
  --navy-light: #6a37b8;
  --green: #2bb673;
  --red: #c62e2e;
  --gray: #7c7392;
  --gray-light: #f4f1f9;
  --border: #e7e1f1;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--gray-light);
  color: #1c2331;
  line-height: 1.5;
}

a { color: inherit; }

#topbar {
  background: var(--navy);
  color: white;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand img {
  height: 32px;
  display: block;
}
.brand .wordmark {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.2px;
  color: white;
}

.topnav {
  display: flex;
  gap: 18px;
  flex: 1;
  margin-left: 28px;
}
.topnav-link {
  color: rgba(255,255,255,0.8);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.topnav-link:hover { color: white; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
}

.topbar-right .who { color: rgba(255,255,255,0.75); }

@media (max-width: 700px) {
  .topnav { display: none; }
}

.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 8px;
  border: none;
  background: var(--orange);
  color: white;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--orange-dark); }
.btn.secondary {
  background: white;
  color: var(--navy);
  border: 1px solid var(--border);
}
.btn.secondary:hover { background: var(--gray-light); }
.btn.ghost {
  background: transparent;
  color: white;
  border: 1px solid rgba(255,255,255,0.35);
}
.btn.ghost:hover { background: rgba(255,255,255,0.1); }
/* .btn.ghost defaults to white text for use in the dark topbar (e.g. "Log
   out"). Anywhere it's used inside a white card (action buttons in tables
   like "Edit"/"Reset password"), it needs a readable color instead, or it's
   invisible white-on-white. */
.card .btn.ghost {
  color: var(--navy);
  border: 1px solid var(--border);
}
.card .btn.ghost:hover { background: var(--gray-light); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.full { width: 100%; text-align: center; }

#app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
}

.center-card {
  max-width: 420px;
  margin: 60px auto;
}

h1 { font-size: 26px; margin: 0 0 6px; }
h2 { font-size: 20px; margin: 0 0 10px; }
h3 { font-size: 16px; margin: 18px 0 6px; color: var(--navy-light); }
p { margin: 0 0 10px; }
.muted { color: var(--gray); font-size: 14px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--navy); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.field textarea { min-height: 70px; resize: vertical; }

.error-box {
  background: #fde8e8;
  border: 1px solid #f3b7b7;
  color: var(--red);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 14px;
}
.success-box {
  background: #e8f7ef;
  border: 1px solid #b9e6cc;
  color: var(--green);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 14px;
}

.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tab {
  padding: 8px 14px;
  border-radius: 20px;
  background: white;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray);
}
.tab.active { background: var(--navy); color: white; border-color: var(--navy); }

.progress-summary {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}
.progress-ring-label { font-size: 32px; font-weight: 800; color: var(--navy); }
.progress-bar-track {
  flex: 1;
  height: 10px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--orange);
}

.module-list { display: flex; flex-direction: column; gap: 12px; }
.module-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.module-card .info { flex: 1; }
.module-card h3 { margin: 0 0 4px; font-size: 16px; color: #1c2331; }
.module-card .meta { font-size: 13px; color: var(--gray); }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  margin-left: 8px;
}
.badge.done { background: #e8f7ef; color: var(--green); }
.badge.progress { background: #fff4e5; color: var(--orange-dark); }
.badge.todo { background: var(--gray-light); color: var(--gray); }
.badge.locked { background: var(--gray-light); color: var(--gray); }

.module-card.locked { opacity: 0.6; }
.module-card.locked .btn { cursor: not-allowed; }

.reading-progress { font-size: 13px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; color: var(--gray); }
.reading-progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
  margin-bottom: 18px;
}
.reading-progress-fill { height: 100%; background: var(--orange); transition: width 0.2s ease; }

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--navy-light);
  text-decoration: none;
  font-weight: 600;
}

.section-body p { color: #333; }

.quiz-question { border-top: 1px solid var(--border); padding: 16px 0; }
.quiz-question:first-child { border-top: none; }
.quiz-question .q-text { font-weight: 600; margin-bottom: 10px; }
.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  background: white;
}
.choice:hover { border-color: var(--orange); }
.choice.selected { border-color: var(--navy); background: var(--orange-light); }
.choice.correct { border-color: var(--green); background: #e8f7ef; }
.choice.incorrect { border-color: var(--red); background: #fde8e8; }
.choice.disabled { cursor: default; }
.explain { margin-top: 8px; font-size: 13px; color: var(--gray); background: var(--gray-light); padding: 8px 10px; border-radius: 6px; }

.quiz-score {
  margin-top: 16px;
  padding: 14px;
  border-radius: 8px;
  background: var(--orange-light);
  font-weight: 700;
  color: var(--orange-dark);
}

.scenario-step .prompt { font-weight: 600; margin-bottom: 10px; }
.scenario-feedback { margin-top: 10px; padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.scenario-feedback.correct { background: #e8f7ef; color: var(--green); }
.scenario-feedback.incorrect { background: #fde8e8; color: var(--red); }
.scenario-progress { font-size: 13px; color: var(--gray); margin-bottom: 8px; }

.reflection-fields { display: flex; flex-direction: column; gap: 14px; }

.status-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 18px;
  font-size: 14px;
  font-weight: 600;
}
.status-banner.done { background: #e8f7ef; color: var(--green); }
.status-banner.pending { background: #fff4e5; color: var(--orange-dark); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; font-size: 14px; border-bottom: 1px solid var(--border); }
th { color: var(--gray); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--gray-light); }
td.clickable { cursor: pointer; color: var(--navy-light); font-weight: 600; }
td.clickable:hover { text-decoration: underline; }

.mini-bar-track { width: 90px; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 8px; }
.mini-bar-fill { height: 100%; background: var(--orange); }

.link-row { margin-top: 16px; font-size: 14px; text-align: center; }
/* Covers both patterns used in the app: a wrapping <div class="link-row">
   containing a plain <a>, and an <a class="link-row"> used directly (its
   own color/cursor/underline needs to be set here too, or it inherits the
   global `a { color: inherit }` rule and just looks like plain underlined
   text instead of an actionable link). */
.link-row a, a.link-row { color: var(--orange-dark); font-weight: 600; text-decoration: none; cursor: pointer; }
a.link-row:hover, .link-row a:hover { text-decoration: underline; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

@media (max-width: 600px) {
  .grid-2 { grid-template-columns: 1fr; }
  .module-card { flex-direction: column; align-items: flex-start; }
}

/* ---- dashboard two-column layout (main content + sidebar filler) ---- */

.dash-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  align-items: start;
}
.dash-main { min-width: 0; }
.dash-sidebar { display: flex; flex-direction: column; gap: 16px; }

/* KPI tile row on the admin Statistics page */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 500px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  .dash-layout { grid-template-columns: 1fr; }
  .dash-sidebar { flex-direction: row; flex-wrap: wrap; }
  .dash-sidebar > * { flex: 1 1 220px; }
}

.sidebar-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.sidebar-card-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--navy-light);
  margin-bottom: 10px;
}
.fun-fact-card { background: var(--orange-light); border-color: #ffd9bd; }
.fun-fact-card .sidebar-card-title { color: var(--orange-dark); }

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.stat-row:last-of-type { border-bottom: none; }
.stat-row strong { color: var(--navy); }

.stat-tile {
  background: var(--gray-light);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}
.stat-tile-value { font-size: 22px; font-weight: 800; color: var(--navy); }
.stat-tile-label { font-size: 12px; color: var(--gray); margin-top: 2px; }

.hero-card { background: linear-gradient(135deg, #fff 55%, var(--orange-light) 100%); }

/* ---- mini calendar ---- */

.mini-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  text-align: center;
}
.cal-cell {
  font-size: 12px;
  padding: 5px 0;
  border-radius: 5px;
  color: #1c2331;
}
.cal-cell.cal-weekday {
  font-weight: 700;
  color: var(--gray);
  font-size: 11px;
  padding-bottom: 6px;
}
.cal-cell.empty { visibility: hidden; }
.cal-cell.today {
  background: var(--navy);
  color: white;
  font-weight: 700;
}
.cal-cell.has-event {
  position: relative;
  cursor: default;
}
.cal-cell.has-event::after {
  content: "";
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--orange);
}
.cal-cell.today.has-event::after { background: white; }

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.cal-nav {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 24px;
  height: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--navy-light);
  font-size: 13px;
}
.cal-nav:hover { background: var(--gray-light); }

.cal-upcoming {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cal-upcoming-item {
  font-size: 12px;
  color: #1c2331;
}
.cal-upcoming-date {
  font-weight: 700;
  color: var(--orange-dark);
  margin-right: 6px;
}

/* ---- stage machine (reading / test-mode screens) ---- */

.stage-pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--orange-light);
  color: var(--orange-dark);
  margin-bottom: 10px;
}

.test-mode-card {
  background: var(--navy);
  color: white;
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 18px;
}
.test-mode-card h2 { color: white; }
.test-mode-card .muted { color: rgba(255,255,255,0.7); }
.test-mode-card .stage-progress { color: rgba(255,255,255,0.75); }

.test-mode-card .choice { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.18); color: white; }
.test-mode-card .choice:hover { border-color: var(--orange); }
.test-mode-card .choice.selected { border-color: white; background: rgba(255,255,255,0.14); }
.test-mode-card .choice.correct { border-color: #58d69a; background: rgba(26,143,94,0.35); color: white; }
.test-mode-card .choice.incorrect { border-color: #f08a8a; background: rgba(198,46,46,0.35); color: white; }
.test-mode-card .explain { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.9); }
.test-mode-card .quiz-score { background: rgba(255,255,255,0.12); color: white; }
.test-mode-card .scenario-feedback.correct { background: rgba(26,143,94,0.35); color: white; }
.test-mode-card .scenario-feedback.incorrect { background: rgba(198,46,46,0.35); color: white; }

.stage-progress { font-size: 13px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; }
.stage-progress-track {
  height: 6px;
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}
.stage-progress-fill { height: 100%; background: var(--orange); transition: width 0.2s ease; }

.exam-result-summary { font-size: 14px; }
.exam-card.locked { border-color: var(--border); background: var(--gray-light); }

.stage-intro-card { text-align: center; padding: 40px 30px; }
.stage-intro-card .big-icon { font-size: 42px; margin-bottom: 10px; }

.locked-card {
  background: var(--gray-light);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  color: var(--gray);
}

.exam-card {
  border: 2px solid var(--navy);
}

.pass-fail-badge {
  display: inline-block;
  font-size: 15px;
  font-weight: 800;
  padding: 6px 16px;
  border-radius: 20px;
  margin-top: 10px;
}
.pass-fail-badge.pass { background: #e8f7ef; color: var(--green); }
.pass-fail-badge.fail { background: #fde8e8; color: var(--red); }

.score-hero {
  font-size: 44px;
  font-weight: 800;
  text-align: center;
  margin: 10px 0;
}

/* CourtReserve Training: video/walkthrough embeds and the reference-mode
   search box */
.video-embed {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 */
  margin: 14px 0;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}
.video-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.walkthrough-link {
  display: inline-block;
  margin: 10px 0 6px;
}
.search-input {
  width: 100%;
  max-width: 380px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  margin-top: 12px;
}
mark {
  background: var(--orange-light);
  color: var(--orange-dark);
  padding: 0 2px;
  border-radius: 3px;
}
