/* DPT Testing - dark gym mode.
   Brand law: base #0D1117, Oswald display / Roboto UI, green #00A651 is an
   accent and NEVER a button color, gold #FFC72C appears at most once per view
   and is reserved for the money moment (save / PR). Big numbers readable at
   arm's length. */

@font-face {
  font-family: 'Oswald';
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  src: url('/fonts/oswald-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Oswald';
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  src: url('/fonts/oswald-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Oswald';
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: url('/fonts/oswald-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Roboto';
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url('/fonts/roboto-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Roboto';
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  src: url('/fonts/roboto-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Roboto';
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: url('/fonts/roboto-latin-700-normal.woff2') format('woff2');
}

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1f2630;
  --line: #2a3139;
  --text: #e6edf3;
  --muted: #8b949e;
  --green: #00a651;
  --green-soft: rgba(0, 166, 81, 0.16);
  --gold: #ffc72c;
  --gold-soft: rgba(255, 199, 44, 0.14);
  --red: #f85149;
  --font-display: 'Oswald', 'Arial Narrow', sans-serif;
  --font-ui: 'Roboto', system-ui, sans-serif;
  --radius: 12px;
  --tap: 48px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1,
h2,
h3,
.display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

button {
  font-family: var(--font-ui);
  font-size: 16px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: var(--tap);
  padding: 0 18px;
  cursor: pointer;
  touch-action: manipulation;
}
button:active {
  transform: scale(0.985);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button.primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #131313;
  font-weight: 700;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 18px;
}
button.ghost {
  background: transparent;
}
button.danger {
  border-color: var(--red);
  color: var(--red);
  background: transparent;
}

input,
select,
textarea {
  font-family: var(--font-ui);
  font-size: 16px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: var(--tap);
  padding: 8px 14px;
  width: 100%;
}
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--green);
  outline-offset: -1px;
  border-color: var(--green);
}
label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 12px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ------------------------------------------------------------- layout --- */

#topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(13, 17, 23, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
#topbar .brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
#topbar .brand .accent {
  color: var(--green);
}
#conn {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  flex: none;
}
#conn.offline {
  background: var(--muted);
}
#coach-chip {
  margin-left: auto;
  min-height: 40px;
  border-radius: 999px;
  font-weight: 500;
  white-space: nowrap;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 14px 96px;
}

#tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
#tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 58px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  position: relative;
}
#tabbar a svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#tabbar a.active {
  color: var(--text);
}
#tabbar a.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 22%;
  right: 22%;
  height: 3px;
  background: var(--green);
  border-radius: 0 0 3px 3px;
}
#tabbar .badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 24px);
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.spread {
  justify-content: space-between;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 13px;
}
.center {
  text-align: center;
}
hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 14px 0;
}

/* -------------------------------------------------------------- chips --- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
}
.chip.on {
  border-color: var(--green);
  background: var(--green-soft);
}
.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar {
  display: none;
}

/* --------------------------------------------------------------- home --- */

#search {
  font-size: 18px;
  min-height: 54px;
}
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  min-height: 76px;
}
.tile .display {
  font-size: 17px;
}
.tile:active {
  background: var(--panel-2);
}
.search-hit {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  min-height: var(--tap);
}
.search-hit:last-child {
  border-bottom: 0;
}
.search-hit .who {
  flex: 1;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--muted);
  flex: none;
}

/* ------------------------------------------------------- station mode --- */

.test-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.test-btn {
  min-height: 60px;
  text-align: left;
  padding: 10px 14px;
  line-height: 1.25;
}
.test-btn .unit {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
.test-btn.on {
  border-color: var(--green);
  background: var(--green-soft);
}

#station-entry {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 14px;
  align-items: start;
}
@media (max-width: 760px) {
  #station-entry {
    grid-template-columns: 1fr;
  }
  #keypad-wrap {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 58px;
    z-index: 25;
    background: var(--panel);
    border-top: 1px solid var(--line);
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0));
  }
  #roster {
    padding-bottom: 320px;
  }
}

.roster-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 2px solid transparent;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  min-height: 62px;
  border-radius: 10px;
}
.roster-row.active {
  border: 2px solid var(--green);
  background: var(--green-soft);
}
.roster-row.done {
  opacity: 0.62;
}
.roster-row .nm {
  flex: 1;
  font-size: 18px;
  font-weight: 500;
}
.roster-row .prev {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
  line-height: 1.3;
}
.roster-row .val {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  min-width: 86px;
  text-align: right;
}
.roster-row .val.pending {
  color: var(--muted);
  font-size: 15px;
  font-family: var(--font-ui);
}
.roster-row.flash-save {
  animation: flash-save 0.7s ease-out;
}
.roster-row.flash-pr {
  animation: flash-pr 1.1s ease-out;
}
@keyframes flash-save {
  0% {
    background: var(--green-soft);
  }
  100% {
    background: transparent;
  }
}
@keyframes flash-pr {
  0% {
    background: var(--gold-soft);
    border-color: var(--gold);
  }
  100% {
    background: transparent;
  }
}
.pr-tag {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 0.08em;
}

#keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
#keypad button {
  min-height: 62px;
  font-size: 24px;
  font-family: var(--font-display);
  font-weight: 500;
}
#keypad .key-save {
  grid-column: 1 / -1;
  min-height: 66px;
}
#entry-display {
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 700;
  text-align: right;
  padding: 4px 12px;
  min-height: 60px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  margin-bottom: 8px;
  overflow: hidden;
}
#entry-athlete {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 6px;
  min-height: 20px;
}

/* --------------------------------------------------------- athlete page --- */

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.stat {
  background: var(--panel-2);
  border-radius: 10px;
  padding: 10px 12px;
}
.stat .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.stat .num {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
}
.stat .num.gold {
  color: var(--gold);
}
.delta-up {
  color: var(--green);
}
.delta-down {
  color: var(--red);
}
.test-card {
  margin-bottom: 12px;
}
.test-card .hist {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.test-card .hist td,
.test-card .hist th {
  padding: 7px 8px;
  border-top: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}
.test-card .hist th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.test-card .hist td:first-child,
.test-card .hist th:first-child {
  text-align: left;
}
.spark {
  width: 100%;
  height: 44px;
}
.spark polyline {
  fill: none;
  stroke: var(--green);
  stroke-width: 2;
}
.spark circle {
  fill: var(--green);
}

/* ---------------------------------------------------------- leaderboard --- */

.lb-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 18px;
}
@media (max-width: 560px) {
  .lb-grid {
    grid-template-columns: 1fr;
  }
}
.lb-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
}
.lb-row .rank {
  font-family: var(--font-display);
  color: var(--muted);
  width: 22px;
  flex: none;
}
.lb-row .nm {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.lb-row .best {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
}
.lb-row.first .rank {
  color: var(--green);
  font-weight: 700;
}

/* ---------------------------------------------------------------- queue --- */

.q-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}
.q-row input[type='checkbox'] {
  width: 24px;
  height: 24px;
  min-height: 0;
  accent-color: var(--green);
  flex: none;
}
.q-row .what {
  flex: 1;
  line-height: 1.3;
}
.q-row .num {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
}

/* --------------------------------------------------------------- modal --- */

#modal-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: flex-end;
  justify-content: center;
}
#modal-layer.open {
  display: flex;
}
#modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  width: min(560px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom, 0));
}
@media (min-width: 700px) {
  #modal-layer {
    align-items: center;
  }
  #modal {
    border-radius: 16px;
  }
}

/* --------------------------------------------------------------- toast --- */

#toast-layer {
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 15px;
  animation: toast-in 0.2s ease-out;
  max-width: 90%;
}
.toast.pr {
  background: var(--gold);
  border-color: var(--gold);
  color: #131313;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.03em;
}
.toast.err {
  border-color: var(--red);
  color: var(--red);
}
@keyframes toast-in {
  from {
    transform: translateY(-8px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

/* --------------------------------------------------------------- login --- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
}
.login-card h1 {
  font-size: 26px;
  margin-bottom: 4px;
}
.login-card h1 .accent {
  color: var(--green);
}
.login-card p {
  color: var(--muted);
  margin-bottom: 18px;
}

/* ---------------------------------------------------------- utilities --- */

.hidden {
  display: none !important;
}
.list-plain {
  list-style: none;
}
table.settings {
  width: 100%;
  border-collapse: collapse;
}
table.settings td,
table.settings th {
  padding: 8px 6px;
  border-top: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}
table.settings th {
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.05em;
}
