/* The coach console is deployed as its own hosting site, so it can't load
   styles from the public site. */
:root {
  --orange: #EB6425;
  --orange-dark: #B8481A;
  --ink: #1B1B1B;
  --muted: #5C5C5C;
  --bg: #FFFFFF;
  --panel: #F6F4F2;
  --line: #E4E4E4;
  --ok: #1E7A3C;
  --ok-bg: #E6F4EA;
  --warn: #8A4B00;
  --warn-bg: #FDF0DF;
  --error: #B3261E;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 18px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 20px 16px 96px; }

h1 { margin: 8px 0 4px; font-size: 1.6rem; }
h2 { margin: 24px 0 8px; font-size: 1.15rem; }

.muted, .empty, .loading { color: var(--muted); }
.error { color: var(--error); min-height: 1.2em; margin: 8px 0; }

.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > label { flex: 1 1 140px; }
.row.between { justify-content: space-between; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 16px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--orange); color: var(--ink);
}
.topbar .brand { font-size: 1.05rem; margin-right: auto; }
.topbar .who { font-weight: 600; }

/* Buttons: big targets for phones and tablets on the gym floor. */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 56px; padding: 12px 20px;
  border: 0; border-radius: 10px;
  background: var(--orange); color: var(--ink);
  font: inherit; font-weight: 700;
  cursor: pointer;
}
.btn.secondary { background: var(--panel); border: 1px solid var(--line); }
.btn.wide { width: 100%; margin-top: 12px; }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn:focus-visible, .card:focus-visible, .athlete:focus-visible, .link:focus-visible {
  outline: 3px solid var(--ink); outline-offset: 2px;
}

.link {
  background: none; border: 0; padding: 8px 0; min-height: 44px;
  font: inherit; color: var(--ink); text-decoration: underline; cursor: pointer;
}
.topbar .link { color: var(--ink); }
.back { margin-top: 4px; }

/* Inputs */
input[type=text], input[type=search], input[type=email], input[type=tel],
input[type=date], input[type=time], input:not([type]) {
  width: 100%; min-height: 52px; padding: 10px 12px;
  border: 1px solid #BDBDBD; border-radius: 10px;
  font: inherit; font-weight: 400; background: #fff; color: var(--ink);
}
label { display: block; margin-top: 12px; font-weight: 600; }
label > input { margin-top: 4px; }
.date-pick input { width: auto; }

fieldset.sex { border: 0; padding: 0; margin: 12px 0 0; display: flex; gap: 16px; align-items: center; }
fieldset.sex legend { font-weight: 600; padding: 0; margin-bottom: 4px; }
fieldset.sex label { margin: 0; display: flex; align-items: center; gap: 6px; min-height: 52px; }
fieldset.sex input { width: 24px; height: 24px; }

.search { margin-top: 16px; }

/* Session cards */
.cards, .athletes { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }
.card, .athlete {
  width: 100%; text-align: left;
  display: grid; gap: 2px;
  padding: 14px 16px; min-height: 64px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  font: inherit; color: var(--ink); cursor: pointer;
}
.card .time { font-weight: 700; }
.card .title { font-size: 1.1rem; }
.card .meta { color: var(--muted); font-size: 0.9rem; }
.card.cancelled { opacity: 0.6; text-decoration: line-through; }

/* Athlete rows */
.athlete .name { font-size: 1.15rem; font-weight: 700; }
.athlete .sub { color: var(--muted); font-size: 0.9rem; }
.athlete .badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.athlete.done { background: var(--ok-bg); border-color: #B7DFC3; }
.athlete:disabled { opacity: 0.6; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 700;
  background: #fff; border: 1px solid var(--line); color: var(--muted);
}
.badge.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: #F2C894; }

.actions { margin-top: 20px; }

/* Toast */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 20;
  max-width: 560px; margin: 0 auto; padding: 14px 18px;
  border-radius: 12px; font-weight: 700;
  background: var(--ink); color: #fff;
  box-shadow: 0 6px 24px rgba(0,0,0,0.25);
}
.toast.error { background: var(--error); }

/* Dialogs */
dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  border: 0; border-radius: 16px; padding: 20px;
  color: var(--ink);
}
dialog::backdrop { background: rgba(0,0,0,0.5); }
dialog h2 { margin-top: 0; }

.duplicate { margin-top: 12px; padding: 12px; background: var(--warn-bg); border-radius: 10px; }

.qr-body { text-align: center; }
.big-id { font-size: 2rem; font-weight: 800; letter-spacing: 0.04em; margin: 4px 0 8px; }
.qr { width: min(280px, 70vw); margin: 12px auto; }
.qr svg { width: 100%; height: auto; display: block; }
.qr-body a { color: var(--orange-dark); }

/* Test days */
.station select, #form-event select, #form-screen select { width: 100%; min-height: 48px; font: inherit; }
.protocol { margin: 4px 0 0; font-size: 0.95rem; }
.sync { padding: 8px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.badge.stop { background: #FBE3E1; color: var(--error); }
.attempt { display: flex; gap: 12px; align-items: center; margin: 8px 0; }
.attempt label:first-child { flex: 1; }
.attempt input[type=number] { width: 100%; min-height: 52px; font-size: 1.3rem; }
.attempt .invalid { white-space: nowrap; font-size: 0.95rem; }
.screen-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 6px 0; }
.screen-item select { width: 96px; }
.best { font-weight: 700; min-height: 1.2em; }
.confirm { padding: 12px; border-radius: 8px; background: var(--warn-bg); margin: 8px 0; }
.sides { display: flex; gap: 16px; border: 0; padding: 0; margin: 8px 0; }
.sides label { display: flex; gap: 6px; align-items: center; min-height: 44px; }

/* Reports */
textarea { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-top: 4px; resize: vertical; }
#form-report select, #report-filter { width: 100%; min-height: 48px; font: inherit; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.report-results, .report-workouts { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.report-results li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.report-results .val { white-space: nowrap; font-weight: 600; }
.report-workouts li { padding: 10px 12px; border: 1px solid var(--line); border-left: 4px solid var(--orange); border-radius: 8px; }
.report-workouts .wname { font-weight: 700; }
.report-actions { flex-wrap: wrap; }
.wide-dialog { width: min(680px, 96vw); }
#preview-frame { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 8px; background: #F6F4F2; }

/* Coach sign-off (D36) */
.small { font-size: 0.85rem; }
.btn.small { padding: 6px 12px; font-size: 0.9rem; min-height: 36px; }
.badge.stage-applicant { background: #ECECEC; }
.badge.stage-in-training { background: #FFF3C4; }
.badge.stage-ready-to-test { background: #DCEBFF; }
.badge.stage-ready-to-coach { background: #DDF3E2; }
.criteria { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 10px; }
.criteria h2 { margin: 18px 0 2px; }
.criterion { padding: 10px 12px; border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 8px; display: grid; gap: 4px; justify-items: start; }
.criterion.met { border-left-color: #2E7D32; }
.crit-head { display: flex; justify-content: space-between; gap: 10px; width: 100%; }
.crit-head .name { font-weight: 700; }
.crit-head .count { color: var(--muted); white-space: nowrap; }
.criterion p { margin: 0; }
.application { white-space: pre-wrap; background: #FAF8F6; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 0.9rem; }
details summary { cursor: pointer; font-weight: 700; margin: 8px 0; }

/* Athlete details (D37) */
.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 12px 0 16px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 600; word-break: break-word; }
.fields { display: grid; gap: 10px; max-height: 60vh; overflow-y: auto; }
.field label { display: grid; gap: 4px; }
.field .inline { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.plain { list-style: none; padding: 0; margin: 6px 0; display: grid; gap: 4px; }

/* Session ratings (D38) */
.anchors { list-style: none; padding: 10px 12px; margin: 0 0 12px; background: var(--panel); border-radius: 8px; display: grid; gap: 2px; font-size: 0.9rem; }
.rate-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.rate-row { display: grid; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rate-row .name { font-weight: 700; }
.rate-choices { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.rate-choices.words { grid-template-columns: repeat(3, 1fr); }
.rate { min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font: inherit; font-weight: 700; color: var(--ink); cursor: pointer; }
.rate.on { background: var(--orange); border-color: var(--orange-dark); color: #fff; }
.rate-nav { display: flex; gap: 10px; }
.rate-nav .btn { flex: 1; }

/* Menu on the Sessions screen */
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.menu-grid .btn { width: 100%; padding-left: 8px; padding-right: 8px; }

/* Progress: coach analytics (D39) */
.tabs { display: flex; gap: 6px; margin: 4px 0 14px; border-bottom: 1px solid var(--line); }
.tab { flex: 1; border: 0; background: none; font: inherit; font-size: 0.95rem; padding: 10px 4px; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; }
.tab[aria-selected="true"] { color: var(--ink); font-weight: 700; border-bottom-color: var(--orange); }
.chart { width: 100%; height: auto; display: block; margin: 6px 0; }
.legend { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.85rem; }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.test-charts { display: grid; gap: 12px; }
.test-chart { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.test-chart p { margin: 2px 0 0; }
.up { color: var(--ok); }
.down { color: var(--error); }
.group { margin-bottom: 18px; }
.table-wrap { overflow-x: auto; }
.progress-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.progress-table th, .progress-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.progress-table th { color: var(--muted); font-weight: 600; }
.progress-table td.flag { color: var(--warn); background: var(--warn-bg); font-weight: 700; }
.bar { position: relative; display: inline-block; min-width: 80px; height: 22px; background: var(--panel); border-radius: 4px; overflow: hidden; vertical-align: middle; }
.bar .fill { position: absolute; inset: 0 auto 0 0; background: var(--ok-bg); }
.bar .bar-text { position: relative; padding: 0 6px; line-height: 22px; font-size: 0.85rem; }
.note { background: var(--warn-bg); color: var(--warn); border-radius: 6px; padding: 6px 10px; margin: 4px 0 10px; }
.callout-line { background: var(--panel); border-left: 4px solid var(--orange); border-radius: 6px; padding: 8px 12px; font-weight: 600; font-size: 0.9rem; }
.attention { border: 1px solid var(--warn); background: var(--warn-bg); border-radius: 8px; padding: 10px 12px; margin: 0 0 14px; }
.attention h2 { margin: 0 0 4px; font-size: 1.05rem; color: var(--warn); }
.attention .athlete { background: var(--bg); }
