:root {
  --court:        #0B4A34;
  --court-deep:   #06301F;
  --line:         #F0B429;
  --chalk:        #ECEFEA;
  --card:         #FFFFFF;
  --ink:          #12211B;
  --muted:        #6E7C75;
  --hair:         #D9DED8;
  --alert:        #B33A22;

  --radius:  10px;
  --pad:     18px;
  --nav-h:   64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--chalk);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, .num {
  font-family: "Barlow Condensed", Inter, sans-serif;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0;
}

a { color: var(--court); }

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

.boot { padding: 40vh 24px; text-align: center; color: var(--muted); }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px var(--pad);
  background: var(--court-deep);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .mark {
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  font-size: 24px;
  line-height: 1;
  border-left: 4px solid var(--line);
  padding-left: 10px;
}
.topbar .who { margin-left: auto; font-size: 13px; color: #B9C7BF; text-align: right; }

/* ---------- layout ---------- */
.view { padding: var(--pad); display: grid; gap: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  padding: 16px;
}
.card h2 { font-size: 21px; margin-bottom: 4px; }
.card .sub { color: var(--muted); font-size: 14px; }

/* ---------- scoreboard hero ---------- */
.board {
  background: var(--court);
  color: #fff;
  border-radius: var(--radius);
  padding: 20px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  align-items: center;
}
.board .rate {
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  font-size: 68px;
  line-height: 0.82;
  color: var(--line);
  font-variant-numeric: tabular-nums;
}
.board .rate span { font-size: 26px; }
.board .caption { font-size: 14px; color: #C6D5CD; }
.board .caption strong { color: #fff; font-weight: 600; }
.board .split { display: flex; gap: 18px; margin-top: 8px; font-size: 13px; color: #C6D5CD; }
.board .split b { display: block; font-family: "Barlow Condensed", sans-serif; font-size: 22px; color: #fff; }

/* ---------- lists ---------- */
.rowitem {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--hair);
}
.rowitem:last-child { border-bottom: 0; padding-bottom: 0; }
.rowitem .grow { flex: 1; min-width: 0; }
.rowitem .title { font-weight: 500; }
.rowitem .meta { font-size: 13px; color: var(--muted); }

.datechip {
  width: 46px;
  text-align: center;
  border: 1px solid var(--hair);
  border-radius: 8px;
  padding: 4px 0;
  flex: none;
}
.datechip .d { font-family: "Barlow Condensed", sans-serif; font-size: 22px; line-height: 1; }
.datechip .m { font-size: 11px; color: var(--muted); }

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

/* ---------- pills ---------- */
.pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--chalk);
  color: var(--muted);
  white-space: nowrap;
}
.pill.ok { background: #DCEFE3; color: #146240; }
.pill.late { background: #FCEFD2; color: #8A5D06; }
.pill.absent { background: #F6DED8; color: #8C2A15; }

/* ---------- forms ---------- */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
input, select, textarea {
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--hair);
  border-radius: 8px;
  padding: 11px 12px;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--court);
  outline-offset: 1px;
}
textarea { min-height: 76px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  background: var(--court);
  color: #fff;
}
button:disabled { opacity: .55; cursor: default; }
button.wide { width: 100%; }
button.ghost { background: transparent; color: var(--court); border: 1px solid var(--hair); }
button.small { padding: 7px 11px; font-size: 13px; border-radius: 7px; }
button.danger { background: var(--alert); }

.codeinput {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 34px;
  letter-spacing: .22em;
  text-align: center;
  text-transform: uppercase;
  padding: 14px 12px;
}

/* ---------- QR panel ---------- */
.qrpanel {
  background: var(--court-deep);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  color: #fff;
}
.qrpanel canvas {
  background: #fff;
  padding: 12px;
  border-radius: 8px;
  width: min(300px, 78vw) !important;
  height: auto !important;
}
.qrpanel .code {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 40px;
  letter-spacing: .2em;
  color: var(--line);
  margin-top: 14px;
  line-height: 1;
}
.qrpanel .hint { font-size: 13px; color: #B9C7BF; margin-top: 8px; }

#reader { border-radius: 8px; overflow: hidden; }

/* ---------- table ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--hair); }
.table th { font-weight: 500; color: var(--muted); font-size: 12px; }
.table td.n, .table th.n { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- bottom nav ---------- */
.nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff;
  border-top: 1px solid var(--hair);
  display: flex;
  z-index: 30;
}
.nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
  border-top: 3px solid transparent;
}
.nav a.on { color: var(--court); border-top-color: var(--line); }
.nav svg { width: 21px; height: 21px; }

/* ---------- login ---------- */
.login {
  min-height: 100vh;
  display: grid;
  align-content: center;
  gap: 20px;
  padding: 28px 24px;
  background: var(--court-deep);
  color: #fff;
}
.login .brand {
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  font-size: 54px;
  line-height: .9;
  border-left: 6px solid var(--line);
  padding-left: 14px;
}
.login p { color: #B9C7BF; font-size: 14px; margin: 0; }
.login .box { background: #fff; color: var(--ink); border-radius: var(--radius); padding: 20px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 20px);
  transform: translate(-50%, 16px);
  background: var(--ink);
  color: #fff;
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 14px;
  max-width: 88vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--alert); }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
