/* =============================================================
   DUBC scores — site styling
   Palatinate header, white page, mobile first.
   ============================================================= */

:root {
  /* palatinate */
  --pal:        #b7a5dc;   /* header bar */
  --pal-dark:   #5a4788;   /* links, accents */
  --pal-pale:   #f4f1fa;   /* panel fills */
  --pal-ink:    #241a3b;   /* text on the header */

  /* page */
  --bg:     #ffffff;
  --text:   #1a1a1a;
  --muted:  #6b7280;
  --line:   #e6e6ea;
  --line2:  #d2d2da;   /* a touch stronger, for outlining a whole block */
  --today:  #fdf6dd;

  --radius: 10px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--pal-dark); }

/* -------------------------------------------------------------
   Header
   ------------------------------------------------------------- */

.site {
  background: var(--pal);
  color: var(--pal-ink);
  border-bottom: 1px solid rgba(0, 0, 0, .08);
}

.bar {
  max-width: 900px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .01em;
  color: var(--pal-ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand span { font-weight: 400; }

.links {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.links a {
  color: var(--pal-ink);
  text-decoration: none;
  font-size: 15px;
  padding: 8px 12px;
  border-radius: 8px;
}
.links a:hover { background: rgba(255, 255, 255, .45); }
.links a.on    { background: #fff; font-weight: 600; }

.links .who {
  align-self: center;
  padding: 0 4px 0 10px;
  font-size: 14px;
  opacity: .75;
  white-space: nowrap;
}
.drawer .who {
  display: block;
  padding: 13px 16px 4px;
  font-size: 14px;
  opacity: .75;
}

/* hamburger, phones only */
.burger {
  margin-left: auto;
  display: none;
  width: 44px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: 1px solid rgba(0, 0, 0, .18);
  border-radius: 8px;
  color: var(--pal-ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.drawer { display: none; }
.drawer.open {
  display: block;
  border-top: 1px solid rgba(0, 0, 0, .08);
}
.drawer a {
  display: block;
  padding: 13px 16px;
  color: var(--pal-ink);
  text-decoration: none;
  border-bottom: 1px solid rgba(0, 0, 0, .06);
}
.drawer a.on { font-weight: 700; }

@media (max-width: 620px) {
  .links  { display: none; }
  .burger { display: block; }
}

/* -------------------------------------------------------------
   Page furniture
   ------------------------------------------------------------- */

.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 64px;
}

h1 { font-size: 21px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 24px 0 8px; }

.sub {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 18px;
}

.back {
  display: inline-block;
  margin-top: 24px;
  font-size: 15px;
}

.note {
  background: var(--pal-pale);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 15px;
  color: var(--muted);
}
.note.bad  { background: #fdeaea; border-color: #f0c4c4; color: #8a2f2f; }
.note.good { background: #eaf6ed; border-color: #c3e2cb; color: #255c33; }

/* -------------------------------------------------------------
   Sign in
   ------------------------------------------------------------- */

.signin {
  max-width: 400px;
  margin: 6vh auto 0;
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  padding: 20px;
}
.signin h1  { margin-bottom: 2px; }
.signin .sub { margin-bottom: 18px; }
.signin .note { margin-bottom: 16px; }
.signin .btn { width: 100%; }

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}
.field label { font-size: 14px; color: var(--muted); }
.field input {
  font: inherit;
  font-size: 16px;            /* stops iOS zooming in */
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
}
.field input:focus { outline: 2px solid var(--pal); outline-offset: -1px; }

/* -------------------------------------------------------------
   Main menu
   ------------------------------------------------------------- */

.menu {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.menu a {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
}
.menu a:hover { border-color: var(--pal); background: var(--pal-pale); }

.menu .label { font-weight: 600; display: block; }
.menu .desc  { color: var(--muted); font-size: 14px; }
.menu .soon  { color: var(--muted); font-size: 13px; float: right; }

/* -------------------------------------------------------------
   Attendance figures
   ------------------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  text-align: center;
}
.stat .pc {
  display: block;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat .of {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}
.stat .what {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

/* a squad's name above its own block of the ranking */
.grid tbody tr.squadhead td {
  background: var(--pal-pale);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--pal-dark);
  padding: 5px 10px;
}

/* the ranking column stands out slightly */
.grid th.ranked, .grid td.ranked { background: var(--pal-pale); font-weight: 600; }
.grid .rank { min-width: 34px; text-align: right; color: var(--muted); }

/* -------------------------------------------------------------
   Athlete — one small card per session
   ------------------------------------------------------------- */

.logcard {
  border: 1px solid var(--line2);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
}

.loghead {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 14px;
}
.loghead .date { font-weight: 700; min-width: 74px; }
.loghead a     { font-weight: 600; text-decoration: none; }
.loghead .meta { color: var(--muted); }
.loghead .pill { margin-left: auto; }

.grid.mini {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 8px 0 0;
}
.grid.mini table { font-size: 14px; width: 100%; }
.grid.mini th, .grid.mini td { padding: 5px 10px; }
.grid.mini th:last-child, .grid.mini td:last-child { border-right: 0; }
.grid.mini thead th {
  background: var(--pal-pale);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.grid.mini td.val { font-weight: 600; }

.logcomment {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* -------------------------------------------------------------
   View — the two pickers
   ------------------------------------------------------------- */

.pickers {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;          /* one under another on a phone */
}
@media (min-width: 620px) {
  .pickers { grid-template-columns: repeat(2, 1fr); }   /* 2 x 2 on anything bigger */
}

.picker {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.picker h2  { margin: 0 0 2px; font-size: 17px; }
.picker .sub { margin-bottom: 12px; }

.picker select {
  font: inherit;
  font-size: 16px;            /* stops iOS zooming in */
  width: 100%;
  padding: 11px 10px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
}
.picker .btn { width: 100%; }

/* -------------------------------------------------------------
   Week programme
   ------------------------------------------------------------- */

.weeknav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 18px;
}
.weeknav a {
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 14px;
  white-space: nowrap;
}
.weeknav .range {
  font-weight: 600;
  text-align: center;
  font-size: 15px;
}

.day {
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}
.day.is-today { border-color: var(--pal); }

.day h2 {
  margin: 0;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  background: var(--pal-pale);
  border-bottom: 1px solid var(--line);
}
.day.is-today h2 { background: var(--today); }
.day h2 .tag { float: right; font-weight: 400; color: var(--muted); }

.session {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 3px 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}
.session:last-child { border-bottom: 0; }
.session:hover { background: var(--pal-pale); }

.session .time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  min-width: 52px;
}
.session .name   { font-weight: 600; }
.session .meta   { color: var(--muted); font-size: 14px; }
.session .status {
  margin-left: auto;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.session .status.done { color: var(--pal-dark); font-weight: 600; }

.empty { padding: 12px 14px; color: var(--muted); font-size: 14px; }

@media (max-width: 560px) {
  .session { padding: 13px 14px; }
  .session .meta   { width: 100%; }
  .session .status { margin-left: 0; width: 100%; }
}

/* -------------------------------------------------------------
   Session page
   ------------------------------------------------------------- */

.sessionhead {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.sessionhead .sub { margin-bottom: 12px; }

/* View / Edit switch */
.modes {
  margin-left: auto;
  display: flex;
  border: 1px solid var(--pal);
  border-radius: 8px;
  overflow: hidden;
  font-size: 15px;
}
.modes a, .modes span {
  padding: 9px 16px;
  text-decoration: none;
  color: var(--pal-dark);
  background: #fff;
}
.modes .on {
  background: var(--pal);
  color: var(--pal-ink);
  font-weight: 700;
}
.modes .on.editing { background: #f3c969; }

.editbar {
  background: #fdf3d7;
  border: 1px solid #edd9a3;
  border-radius: var(--radius);
  padding: 9px 14px;
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 600;
}

.btn {
  font: inherit;
  font-weight: 600;
  padding: 12px 18px;
  border: 0;
  border-radius: 8px;
  background: var(--pal-dark);
  color: #fff;
  cursor: pointer;
}
.btn:hover { background: #46376b; }

.btn.small { padding: 7px 12px; font-size: 14px; }
.btn.danger { background: #a33a3a; }
.btn.danger:hover { background: #8a2f2f; }

.footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.rowbuttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 18px;
}

.grid table.admin .rownum { color: var(--muted); font-size: 13px; text-align: right; }
.grid table.admin .tickcell { text-align: center; }
.grid table.admin .tickcell input { width: 18px; height: 18px; }

.footer-actions form { margin: 0; }

/* -------------------------------------------------------------
   Editing the programme
   ------------------------------------------------------------- */

.grid table.admin { font-size: 14px; }
.grid table.admin td, .grid table.admin th { vertical-align: top; }
.grid table.admin input[type="text"],
.grid table.admin input[type="date"],
.grid table.admin input[type="time"],
.grid table.admin select {
  font: inherit;
  font-size: 15px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: inherit;
  max-width: 100%;
}
.grid table.admin input.wide   { width: 190px; }
.grid table.admin input.narrow { width: 72px; }

.grid table.admin .tick {
  display: block;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.7;
}
.grid table.admin .tick input { margin-right: 5px; }

.grid table.admin tr.locked td { background: #faf9fc; }
.grid table.admin tr.addrow td { background: var(--pal-pale); }

.grid table.admin .counts { font-size: 13px; color: var(--muted); white-space: nowrap; }
.grid table.admin .actions { white-space: nowrap; }
.grid table.admin .actions .btn { margin: 0 0 6px; display: block; width: 100%; }

/* order / filter bar above the grid */
.gridtop {
  display: flex;
  align-items: center;
  gap: 10px 14px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.gridtop .sub { margin: 0 auto 0 0; }   /* pushes the controls to the right */

.sortby {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
}
.sortby .label { color: var(--muted); margin-right: 2px; }
.sortby a {
  text-decoration: none;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--pal-dark);
}
.sortby a.on {
  background: var(--pal);
  border-color: var(--pal);
  color: var(--pal-ink);
  font-weight: 700;
}

@media (max-width: 560px) {
  .gridtop .sub { margin: 0; width: 100%; }
  .sortby { width: 100%; }
  .sortby a { flex: 1; text-align: center; }
}

/* the same control, used on its own under a grid */
.sortby.extras { margin: 4px 0 20px; }

/* -------------------------------------------------------------
   The grid
   ------------------------------------------------------------- */

.grid {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  -webkit-overflow-scrolling: touch;
}

.grid table {
  border-collapse: collapse;
  width: 100%;
  font-size: 15px;
}

.grid th, .grid td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
}
.grid tbody tr:last-child th, .grid tbody tr:last-child td { border-bottom: 0; }

.grid thead th {
  background: var(--pal-pale);
  font-size: 13px;
  font-weight: 700;
  vertical-align: bottom;
  border-bottom: 1px solid var(--line);
}

/* first athlete column stays put when scrolling sideways */
.grid th.name {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #fff;
  font-weight: 600;
  min-width: 96px;
  white-space: normal;      /* long names wrap rather than widen the table */
}
.grid thead th.name { background: var(--pal-pale); z-index: 2; }

.grid .idcol { color: var(--muted); }
.grid thead th.idcol { color: inherit; }

/* faint banding so the eye can follow a row across */
.grid tbody tr:nth-child(even) td,
.grid tbody tr:nth-child(even) th.name { background: #fafafa; }
.grid tbody tr td.ranked { background: var(--pal-pale); }

.grid .unit {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
}

.grid td.val { font-variant-numeric: tabular-nums; }
.grid td.val a { color: inherit; text-decoration: none; }

/* the attendance mark shown beside a score */
.marktag {
  display: inline-block;
  margin-left: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  vertical-align: 1px;
}
.grid td.val a:hover { text-decoration: underline; }

/* editable boxes — these stretch, so the table fills the page */
.cell {
  font: inherit;
  font-variant-numeric: tabular-nums;
  width: 100%;
  min-width: 62px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: inherit;
}
.cell:focus { outline: 2px solid var(--pal); outline-offset: -1px; }

/* a new account's login details, shown once */
.credentials {
  border: 2px solid var(--pal-dark);
  border-radius: var(--radius);
  background: var(--pal-pale);
  padding: 16px 18px;
  margin-bottom: 20px;
}
.credentials h2 { margin: 0 0 6px; font-size: 17px; }
.credentials p  { margin: 0 0 10px; font-size: 15px; }
.credentials p.small { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.credentials dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  margin: 0;
  font-size: 17px;
}
.credentials dt { color: var(--muted); font-size: 14px; align-self: center; }
.credentials dd {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  user-select: all;
}

.grid table.admin td.username { font-weight: 600; white-space: nowrap; }
.grid table.admin td.username .unit { display: inline; margin-left: 6px; }

/* picking athletes for an individual session */
h3.squadname {
  margin: 18px 0 6px;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--pal-dark);
}
.ticklist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 2px 14px;
}
.ticklist .tick { display: block; padding: 6px 0; font-size: 15px; }
.ticklist .tick input { margin-right: 8px; width: 18px; height: 18px; vertical-align: -3px; }

/* "Session: [ all ]" above a list */
.filterbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filterbar label { font-size: 14px; color: var(--muted); }
.filterbar select {
  font: inherit;
  font-size: 15px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
  max-width: 100%;
}

/* heading above an athlete doing something other than the programmed session */
h2.altsession {
  margin: 22px 0 8px;
  font-size: 16px;
}
h2.altsession .unit {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 8px;
}

.swap { font: inherit; font-size: 14px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }

/* the note at the end of a row: wider, and plain text rather than figures */
.cell.note {
  min-width: 160px;
  font-variant-numeric: normal;
  text-align: left;
}
.grid td.note-cell {
  white-space: normal;
  min-width: 150px;
  max-width: 280px;
  color: var(--muted);
  font-size: 14px;
}
.cell.saving { border-color: var(--pal); }
.cell.saved  { border-color: #2e9e4f; }
.cell.failed { border-color: #cc3333; background: #fff6f6; }

.att {
  font: inherit;
  width: 100%;
  min-width: 76px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.att.saved  { border-color: #2e9e4f; }
.att.failed { border-color: #cc3333; }

/* attendance colours */
.att-y     { background: #d8f0dd; }
.att-n     { background: #f8d7d7; }
.att-exc   { background: #e6e6e9; }
.att-other { background: #fbeeba; }

/* ...and the same inside a grid, where the row banding would otherwise win */
.grid tbody tr td.att-y     { background: #d8f0dd; }
.grid tbody tr td.att-n     { background: #f8d7d7; }
.grid tbody tr td.att-exc   { background: #e6e6e9; }
.grid tbody tr td.att-other { background: #fbeeba; }

/* attendance month grid */
.grid th.daycol {
  text-align: center;
  min-width: 34px;
  padding: 6px 4px;
}
.grid th.daycol .unit { font-size: 10px; }

.grid td.mark {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  min-width: 34px;
  padding: 6px 4px;
}

/* the two percentage columns stay in view on the right */
.grid .sum {
  position: sticky;
  z-index: 1;
  width: 66px;
  min-width: 66px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  background: #fff;
  border-left: 1px solid var(--line2);
}
.grid .sum1 { right: 66px; }
.grid .sum2 { right: 0; }
.grid thead th.sum { background: var(--pal-pale); z-index: 2; font-size: 12px; }
.grid tbody tr:nth-child(even) td.sum { background: #fafafa; }

.pill {
  display: inline-block;
  min-width: 42px;
  text-align: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

@media (max-width: 560px) {
  .modes { margin-left: 0; }
  .grid th, .grid td { padding: 7px 8px; }
  .grid th.name { min-width: 84px; }
  .cell { min-width: 58px; font-size: 16px; }  /* 16px stops iOS zooming in */
  .att  { font-size: 16px; }
}
