/* Foundations: colors, text, buttons, forms, cards, tables, pills, dialogs, toasts, icons and small helpers */
:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --ink: #16202e;
  --muted: #5b6477; /* readable (4.5:1) on white and on the light tints used for rows and highlights */
  --line: #dde3ea;
  --line2: #eef1f5;
  --brand: #1d4ed8;
  --brand-ink: #ffffff;
  --side: #0f1b2d;
  --side-ink: #c9d4e3;
  --ok: #16803c;
  --warn: #b45309;
  --danger: #c0262d;
  --red: #d62828;
  --green: #15925a;
  --live: #be123c;
  --st-call: #9a4a06; /* Report now */
  --st-call-bg: #fff1d6;
  --st-queue: #1d4ed8; /* on deck, in progress */
  --st-queue-bg: #e0ebff;
  --radius: 10px;
  --card-pad: 16px 18px;
  --cell-h: 58px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); font-size: 14px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
/* a link inside grey help text must look like a link (colour alone isn't enough there) */
p a, small a, .muted a, .field small a { text-decoration: underline; text-underline-offset: 2px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 0 0 8px; }
code, .mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.err { color: var(--danger); }
.boot { padding: 60px; text-align: center; font-size: 18px; color: var(--muted); }
.boot .btn { margin-top: 16px; }
.btn { display: inline-flex; vertical-align: middle; align-items: center; justify-content: center; gap: 6px; padding: 7px 13px; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none !important; line-height: 1.2; }
.btn:hover { background: #f5f7fa; border-color: #c7cfd9; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: #1a43bd; }
.btn-outline { border-color: #9db4ee; color: var(--brand); font-weight: 600; }
.btn-outline:hover { background: #eef3ff; border-color: var(--brand); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #a61f25; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 6px; min-height: 26px; }
.btn-lg { padding: 11px 20px; font-size: 16px; }
.icon-btn { border: 0; background: none; cursor: pointer; padding: 2px 5px; color: var(--muted); font-size: 12px; }
.icon-btn:disabled { opacity: .25; }
.link { border: 0; background: none; color: var(--brand); cursor: pointer; padding: 0; font: inherit; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.btn:focus-visible, .link:focus-visible, .icon-btn:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
textarea { width: 100%; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12px; font-weight: 600; color: #3b4758; }
.field small { color: var(--muted); font-size: 12.5px; line-height: 1.45; max-width: 72ch; }
.field.sm { width: 150px; }
.field.xs { width: 90px; }
.field.inline { flex-direction: row; align-items: center; gap: 6px; }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.check input { width: 16px; height: 16px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; align-items: start; }
.form-grid h2 { margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--line2); }
.form-grid h2:first-child { border: 0; padding: 0; margin: 0; }
.span2 { grid-column: span 2; }
.inline-fields { display: flex; flex-wrap: wrap; gap: 12px; }
.check-grid { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 12px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; background: #eef1f5; color: #475467; font-size: 11px; font-weight: 600; vertical-align: middle; }
.pill.ok { background: #dcf5e6; color: #166534; }
.pill.warn { background: #fff1d6; color: #a14a08; }
.pill.live { background: #ffe0e6; color: var(--live); }
.pill.muted { background: #f3f4f6; color: var(--muted); }
.pill.st-onmat { background: #ffe0e6; color: var(--live); }
.pill.st-queued { background: #e0ebff; color: var(--brand); }
.pill.st-done { background: #dcf5e6; color: #166534; }
.pill.st-verify { background: #fff1d6; color: #a14a08; }
/* (0.51) one meaning per color on every screen: red = being wrestled, amber = Report now (and real warnings),
   blue = on deck / in the hole / in progress, green = done, grey = idle */
.pill.st-report { background: var(--st-call-bg); color: var(--st-call); }
.pill { font-size: 12px; padding: 2px 9px; }
.badge { margin-left: auto; background: var(--danger); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 700; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--card-pad); margin-bottom: 16px; }
.card.flush { padding: 0; overflow: auto; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.card.callout { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: #f5f8ff; border-color: #cfdcff; }
.card.callout.warn { background: #fffaf0; border-color: #f5d9a8; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--line); background: #fafbfc; position: sticky; top: 0; }
.table td { padding: 8px 10px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
.table.compact td { padding: 5px 8px; }
.table tr.dim td { color: var(--muted); } /* (a colour, not see-through: still readable) */
.table tr.dim td .btn { opacity: .8; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #f7f9fc; }
.table td.win { font-weight: 700; }
.table td.actions { text-align: right; white-space: nowrap; }
/* a card holding a table: the first column lines up with the card's heading */
.card .table th:first-child, .card .table td:first-child { padding-left: 18px; }
.card .table th:last-child, .card .table td:last-child { padding-right: 18px; }
/* tablets: a table wider than the screen keeps its row buttons in view (they stick to the right edge) */
@media (max-width: 1000px) {
  .card.flush .table td.actions { position: sticky; right: 0; background: #fff; box-shadow: -8px 0 8px -8px rgba(15, 27, 45, .18); }
  .table .hide-sm { display: none; }
  /* low-value columns step aside on a tablet: Teams → Coach, Coaches, Points; Wrestlers → Grade, Season; Entries → Entered */
  .teams-table tr > :nth-child(4), .teams-table tr > :nth-child(5), .teams-table tr > :nth-child(7),
  .wrestlers-table tr > :nth-child(4), .wrestlers-table tr > :nth-child(5),
  .entries-table tr > :nth-child(7) { display: none; }
}
.table td.actions .btn { margin-left: 4px; }
.scroll-box { max-height: 360px; overflow: auto; }
.scroll-box.tall { max-height: 520px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > .card { margin-bottom: 0; }
.grid2 { margin-bottom: 16px; }
.modal-wrap { position: fixed; inset: 0; background: rgba(15,27,45,.45); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: #fff; color: var(--ink); border-radius: 14px; width: min(520px, 100%); max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-wide { width: min(820px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line2); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal .check + .check, .modal .field + .check, .modal select + .check { margin-top: 10px; }
.modal .row > .check + .check { margin-top: 0; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line2); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: 420px; }
.toast { background: #1f2937; color: #fff; padding: 11px 15px; border-radius: 9px; box-shadow: 0 6px 20px rgba(0,0,0,.25); transition: opacity .35s, transform .35s; }
.toast-success { background: #166534; }
.toast-error { background: #9f1c22; }
.toast.out { opacity: 0; transform: translateY(8px); }
.sortable { padding-left: 22px; }
.sortable li { padding: 5px 0; }
.pill { white-space: nowrap; }
.card-head.pad { padding: 14px 18px 4px; margin: 0; }
.center-pad { text-align: center; padding: 30px 10px; }
.radio-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.radio-row:has(input:checked) { border-color: var(--brand); background: #f3f7ff; }
.radio-row input { margin-top: 3px; width: 16px; height: 16px; }
.radio-row span { display: flex; flex-direction: column; gap: 2px; }
.radio-row small { color: var(--muted); }
.row.top { align-items: flex-start; }
[hidden] { display: none !important; }
.modal-wrap { grid-template-columns: minmax(0, 1fr); }
.modal { min-width: 0; max-width: 100%; }
.modal .field select, .modal .field textarea, .modal .field input { max-width: 100%; min-width: 0; }
.version-bar { position: sticky; top: 0; z-index: 200; background: #b42318; color: #fff; padding: 10px 16px; font-size: 14px; line-height: 1.4; }
.version-bar .btn { margin: 0 6px; background: #fff; color: #b42318; border-color: #fff; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--brand); }
th.sortable .sort-ind { margin-left: 4px; font-size: 10px; color: var(--muted); }
th.sortable.sorted { color: var(--brand); }
th.sortable.sorted .sort-ind { color: var(--brand); }
tr.row-click { cursor: pointer; }
tr.row-click:hover td { background: #f5f8ff; }
svg.ic { width: 1.1em; height: 1.1em; flex: 0 0 auto; vertical-align: -0.18em; }
.stop-btn svg.ic { width: 13px; height: 13px; vertical-align: -2px; }
.logo-mark { flex: 0 0 auto; vertical-align: middle; }
.btn svg.ic { width: 1.05em; height: 1.05em; vertical-align: -0.16em; }
a.pv-mini { display: inline-flex; align-items: center; text-decoration: none; padding: 3px 8px; }
.btn-menu svg.ic, .btn-msg svg.ic, .btn-tv svg.ic, .horn-btn svg.ic { width: 1.1em; height: 1.1em; vertical-align: -0.2em; }
.mat-wait h2 svg.ic { vertical-align: -0.12em; }
.corner-home svg.ic { vertical-align: -0.18em; }
.btn.tint-blue { background: #e8f0ff; border-color: #bcd0fb; color: #1d4ed8; }
.btn.tint-blue:hover { background: #d7e5ff; }
.btn.tint-amber { background: #fff4e0; border-color: #f3cf92; color: #92400e; }
.btn.tint-amber:hover { background: #ffe9c2; }
.btn.tint-red { background: #fff1f0; border-color: #f5c2c0; color: #b42318; }
.btn.tint-red:hover { background: #ffe0de; }
.btn.tint-green { background: #e9f7ef; border-color: #aee3c3; color: #14532d; }
.btn.tint-green:hover { background: #d6f1e1; }
.btn.tint-red svg.ic, .btn.tint-blue svg.ic { width: .95em; height: .95em; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mat-code, code.team-code, [data-copy-text] { cursor: copy; }
.mat-code:hover, code.team-code:hover { background: #eef4ff; border-radius: 6px; }
.mat-code.copied, code.team-code.copied { background: #dcfce7; border-radius: 6px; transition: background .2s; }
/* rehearsal: a tag on every screen (the head table has its bar instead) */
.rh-tag { position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 9000; background: #b91c1c; color: #fff; font: 800 11px/1 system-ui, sans-serif; letter-spacing: .12em; padding: 4px 10px 5px; border-radius: 0 0 6px 6px; box-shadow: 0 2px 8px rgba(0,0,0,.35); pointer-events: none; opacity: .92; }
body.admin-body .rh-tag { display: none; }
body.admin-body.rehearsing #toasts { bottom: 72px; } /* stay above the rehearsal bar */
