/* =========================================================================
   GJMS Cluster V Badminton - Live Ops Dashboard
   Mobile-first. One-handed on Android, patchy data, three staff + principal.
   Palette matches gjms-website: navy + gold, Georgia headings, system body.
   ========================================================================= */

:root {
  --navy: #0b2545;
  --navy-deep: #081b34;
  --navy-mid: #13315c;
  --gold: #b8860b;
  --gold-light: #c9a227;
  --cream: #fbfbf8;
  --ink: #16202e;

  --slate-700: #334155;
  --slate-500: #64748b;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --white: #ffffff;

  --green: #15803d;
  --green-bg: #dcfce7;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --amber: #b45309;
  --amber-bg: #fef3c7;

  --font-head: Georgia, "Times New Roman", serif;
  --font-body: system-ui, "Segoe UI", Roboto, sans-serif;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 2px 10px rgba(8, 27, 52, .10), 0 1px 3px rgba(8, 27, 52, .08);
  --shadow-lg: 0 16px 32px -8px rgba(8, 27, 52, .28);
  --ring: 0 0 0 3px rgba(184, 134, 11, .35);
  --header-h: 56px;
  --tap: 44px;
}

/* ----------------------------- Reset ----------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--slate-100);
  line-height: 1.5;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--navy-mid); }
button { font: inherit; cursor: pointer; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.2; color: var(--navy); font-weight: 700; }
ul { padding: 0; list-style: none; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ------------------------------- Gate ----------------------------------- */
.gate {
  position: fixed; inset: 0; z-index: 100;
  background: linear-gradient(160deg, var(--navy-deep), var(--navy));
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  overflow-y: auto;
}
.gate-card {
  width: 100%; max-width: 420px;
  background: var(--cream);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 20px 18px 18px;
}
.gate-card.shake { animation: shake .4s ease; }
@media (prefers-reduced-motion: reduce) { .gate-card.shake { animation: none; } }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}
.gate-eyebrow {
  text-align: center; color: var(--gold); font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; font-size: 12px;
}
.gate-title {
  text-align: center; font-size: 22px; margin-top: 2px;
}
.gate-sub {
  text-align: center; color: var(--slate-700); font-size: 13px; margin-top: 4px;
}
.gate-label {
  font-size: 12px; font-weight: 700; color: var(--slate-700);
  text-transform: uppercase; letter-spacing: .03em;
  margin-top: 16px; display: block;
}
.who-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px;
}
.who-btn {
  min-height: var(--tap);
  border: 2px solid var(--slate-300);
  background: var(--white);
  border-radius: var(--radius-sm);
  font-weight: 600; font-size: 14px;
  padding: 8px 6px;
}
.who-btn[aria-pressed="true"] {
  border-color: var(--gold);
  background: var(--amber-bg);
  color: var(--navy);
}
.who-other-input {
  margin-top: 8px; width: 100%; min-height: var(--tap);
  border: 2px solid var(--slate-300); border-radius: var(--radius-sm);
  padding: 8px 12px; background: var(--white);
}
.gate-pin {
  width: 100%; min-height: 52px; margin-top: 8px;
  border: 2px solid var(--slate-300); border-radius: var(--radius-sm);
  padding: 8px 14px; font-size: 22px; letter-spacing: .3em;
  text-align: center; background: var(--white);
}
.gate-error {
  color: var(--red); font-size: 13px; font-weight: 600;
  margin-top: 8px; min-height: 18px;
}
.gate-submit {
  width: 100%; min-height: 52px; margin-top: 14px;
  background: var(--navy); color: var(--white);
  border: none; border-radius: var(--radius-sm);
  font-size: 17px; font-weight: 700;
}
.gate-submit:active { background: var(--navy-mid); }
.gate-who-error { color: var(--red); font-size: 12px; margin-top: 4px; min-height: 16px; }

/* -------------------------- Unsaved banner ------------------------------ */
.unsaved-banner {
  position: sticky; top: 0; z-index: 60;
  background: var(--red); color: var(--white);
  padding: 8px 12px; display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; font-size: 13px; font-weight: 600;
}
.unsaved-banner .spacer { flex: 1; }
.unsaved-banner button {
  min-height: var(--tap); padding: 6px 12px; border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,.6); background: rgba(255,255,255,.12); color: var(--white);
  font-weight: 700;
}

/* -------------------------------- Header -------------------------------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--navy); color: var(--white);
  min-height: var(--header-h);
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
}
.app-header h1 {
  font-size: 15px; color: var(--white); flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.countdown-chip {
  font-size: 12px; font-weight: 700; padding: 5px 10px;
  border-radius: 999px; background: var(--navy-mid); color: var(--white);
  white-space: nowrap;
}
.countdown-chip[data-level="amber"] { background: var(--amber); }
.countdown-chip[data-level="red"] { background: var(--red); }
.icon-btn {
  min-width: var(--tap); min-height: var(--tap);
  background: transparent; border: 1px solid rgba(255,255,255,.35);
  border-radius: var(--radius-sm); color: var(--white); font-size: 16px;
}
.icon-btn:active { background: rgba(255,255,255,.15); }
.who-menu { position: relative; }
.who-menu-btn {
  min-height: var(--tap); padding: 6px 10px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.3);
  border-radius: var(--radius-sm); color: var(--white); font-size: 13px; font-weight: 600;
  max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.who-menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--white); color: var(--ink);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  padding: 6px; min-width: 140px; z-index: 55;
}
.who-menu-pop button {
  width: 100%; min-height: var(--tap); text-align: left; padding: 8px 10px;
  background: none; border: none; border-radius: 6px; font-weight: 600;
}
.who-menu-pop button:active { background: var(--slate-100); }

/* -------------------------------- Layout -------------------------------- */
main { max-width: 560px; margin: 0 auto; padding: 12px 12px 32px; }
section { margin-bottom: 20px; }
.section-title {
  font-size: 13px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--slate-700); font-weight: 700; margin-bottom: 8px;
}

/* ------------------------------ Attention -------------------------------- */
.attention-calm {
  background: var(--green-bg); color: var(--green);
  border-radius: var(--radius); padding: 14px 16px;
  font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px;
}
.attn-group {
  background: var(--white); border-radius: var(--radius);
  margin-bottom: 10px; box-shadow: var(--shadow); overflow: hidden;
  border-left: 5px solid var(--slate-300);
}
.attn-group[data-tone="red"] { border-left-color: var(--red); }
.attn-group[data-tone="amber"] { border-left-color: var(--amber); }
.attn-group[data-tone="navy"] { border-left-color: var(--navy); }
.attn-group summary {
  list-style: none; cursor: pointer; padding: 12px 14px;
  display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px;
  min-height: var(--tap);
}
.attn-group summary::-webkit-details-marker { display: none; }
.attn-group summary .count-badge {
  background: var(--slate-100); color: var(--slate-700);
  border-radius: 999px; padding: 2px 9px; font-size: 12px;
}
.attn-group[data-tone="red"] summary .count-badge { background: var(--red-bg); color: var(--red); }
.attn-group[data-tone="amber"] summary .count-badge { background: var(--amber-bg); color: var(--amber); }
.attn-group summary .chevron { margin-left: auto; transition: transform .15s; }
.attn-group[open] summary .chevron { transform: rotate(90deg); }
.attn-list { padding: 0 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.attn-item {
  border: 1px solid var(--slate-200); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 14px;
}
.attn-item .name { font-weight: 700; color: var(--navy); }
.attn-item .meta { color: var(--slate-500); font-size: 12.5px; margin-top: 2px; }
.attn-item .overdue-tag {
  background: var(--red); color: var(--white); font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 999px; margin-left: 6px; vertical-align: middle;
}
.attn-item .arrival-wrong {
  background: var(--red-bg); color: var(--red); border-radius: 6px;
  padding: 6px 8px; margin-top: 6px; font-weight: 700; font-size: 13px;
}
.attn-item .arrival-unknown {
  background: var(--amber-bg); color: var(--amber); border-radius: 6px;
  padding: 6px 8px; margin-top: 6px; font-weight: 700; font-size: 13px;
}
.attn-item .notes { color: var(--slate-700); margin-top: 4px; font-size: 13px; }
.tel-link {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 8px; min-height: var(--tap); padding: 0 14px;
  background: var(--navy); color: var(--white); border-radius: var(--radius-sm);
  font-weight: 700; font-size: 13.5px; text-decoration: none;
}
.tel-link:active { background: var(--navy-mid); }
.tel-link.tel-alt { background: var(--slate-500); }

/* -------------------------------- Hero ----------------------------------- */
.hero-card {
  background: linear-gradient(160deg, var(--navy), var(--navy-mid));
  color: var(--white); border-radius: var(--radius-lg);
  padding: 18px 18px 16px; box-shadow: var(--shadow-lg);
}
.hero-label { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--gold-light); font-weight: 700; }
.hero-number {
  font-family: var(--font-head); font-size: 64px; line-height: 1; margin-top: 4px;
  font-weight: 700;
}
.hero-sub { font-size: 14px; color: var(--slate-200); margin-top: 4px; }
.hero-progress-track {
  height: 10px; border-radius: 999px; background: rgba(255,255,255,.18);
  margin-top: 12px; overflow: hidden;
}
.hero-progress-fill {
  height: 100%; background: var(--gold-light); border-radius: 999px;
  transition: width .4s ease;
}
@media (prefers-reduced-motion: reduce) { .hero-progress-fill { transition: none; } }
.hero-progress-label { display: flex; justify-content: space-between; font-size: 12.5px; margin-top: 6px; color: var(--slate-200); }
.stat-row {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 14px;
}
.stat-tile {
  background: rgba(255,255,255,.10); border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.stat-tile .v { font-size: 20px; font-weight: 700; font-family: var(--font-head); }
.stat-tile .l { font-size: 11.5px; color: var(--slate-200); }

/* --------------------------- Registration cards -------------------------- */
.reg-card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 10px; overflow: hidden;
}
.reg-banner {
  padding: 8px 14px; font-size: 12.5px; font-weight: 700;
}
.reg-banner.bad { background: var(--red); color: var(--white); }
.reg-banner.unknown { background: var(--amber); color: var(--white); }
.reg-card summary {
  list-style: none; cursor: pointer; padding: 12px 14px; min-height: var(--tap);
}
.reg-card summary::-webkit-details-marker { display: none; }
.reg-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.reg-name { font-weight: 700; color: var(--navy); font-size: 15.5px; }
.reg-district { color: var(--slate-500); font-size: 12.5px; margin-top: 1px; }
.reg-chevron { color: var(--slate-500); }
.reg-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 8px; font-size: 12.5px; color: var(--slate-700); }
.reg-meta .pill { background: var(--slate-100); border-radius: 999px; padding: 3px 9px; }
.reg-meta .pill.pickup { background: var(--amber-bg); color: var(--amber); font-weight: 700; }
.reg-detail { padding: 0 14px 14px; border-top: 1px solid var(--slate-200); }
.reg-detail dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin-top: 10px; font-size: 13.5px; }
.reg-detail dt { color: var(--slate-500); }
.reg-detail dd a { font-weight: 600; }

/* ---------------------------------- Cards row helper ---------------------- */
.empty-state {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; text-align: center; color: var(--slate-500); font-size: 14px;
}

/* ------------------------------- Call board ------------------------------ */
.filters-bar {
  position: sticky; top: var(--header-h); z-index: 40;
  background: var(--slate-100); padding: 8px 0 10px;
  display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.filters-bar select, .filters-bar input[type="search"] {
  min-height: var(--tap); border: 1px solid var(--slate-300); border-radius: 999px;
  padding: 0 12px; background: var(--white); font-size: 13px; flex: none;
}
.filters-bar input[type="search"] { flex: 1 1 140px; min-width: 110px; }
.progress-summary { margin-bottom: 10px; }
.caller-bar-row {
  background: var(--white); border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 8px 12px; margin-bottom: 6px;
}
.caller-bar-row .cb-top { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; color: var(--navy); }
.caller-bar-row .cb-sub { font-size: 12px; color: var(--slate-500); margin-top: 2px; }
.bar-track { height: 8px; border-radius: 999px; background: var(--slate-200); margin-top: 5px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--gold); border-radius: 999px; transition: width .3s ease; }
@media (prefers-reduced-motion: reduce) { .bar-fill { transition: none; } }
.caller-bar-row.total .bar-fill { background: var(--navy); }

.call-list { display: flex; flex-direction: column; gap: 10px; }
.call-card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px; border: 2px solid transparent;
  transition: border-color .2s ease;
}
.call-card.is-saving { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .call-card.is-saving { animation: none; opacity: .85; } }
.call-card.is-error { border-color: var(--red); background: #fff8f8; }
.call-card.is-saved { border-color: var(--green); }
.cc-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.cc-name { font-weight: 700; color: var(--navy); font-size: 15px; }
.cc-district { color: var(--slate-500); font-size: 12px; }
.cc-badges { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.badge.prio-A { background: var(--red-bg); color: var(--red); }
.badge.prio-B { background: var(--amber-bg); color: var(--amber); }
.badge.prio-C { background: var(--slate-100); color: var(--slate-700); }
.badge.registered { background: var(--green-bg); color: var(--green); }
.badge.outcome-chip { color: var(--white); }
.badge.outcome-YES { background: var(--green); }
.badge.outcome-NO { background: var(--red); }
.badge.outcome-CALLBACK { background: var(--amber); }
.badge.outcome-NO_ANSWER { background: var(--slate-500); }
.badge.outcome-WRONG_NUMBER { background: var(--navy-mid); }
.cc-principal { font-size: 13px; color: var(--slate-700); margin-top: 6px; }

.cc-status-line { font-size: 12px; margin-top: 6px; font-weight: 700; min-height: 16px; }
.cc-status-line.saving { color: var(--slate-500); }
.cc-status-line.saved { color: var(--green); }
.cc-status-line.error { color: var(--red); }

.cc-actions { margin-top: 10px; }
.cc-call-btn {
  width: 100%; min-height: 48px; background: var(--green); color: var(--white);
  border: none; border-radius: var(--radius-sm); font-weight: 700; font-size: 15px;
  text-decoration: none; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.cc-call-btn:active { filter: brightness(.92); }
.cc-alt-toggle {
  min-height: var(--tap); margin-top: 6px; width: 100%; background: none; border: 1px dashed var(--slate-300);
  border-radius: var(--radius-sm); font-size: 12.5px; color: var(--slate-700);
}
.cc-alt-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.cc-alt-list a {
  min-height: var(--tap); display: flex; align-items: center; padding: 0 10px;
  background: var(--slate-100); border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 600;
}

.cc-outcomes {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px;
}
.cc-outcome-btn {
  min-height: 44px; border-radius: var(--radius-sm); border: 2px solid var(--slate-300);
  background: var(--white); font-weight: 700; font-size: 13px; padding: 4px 6px;
}
.cc-outcome-btn:nth-child(5) { grid-column: 1 / -1; }
.cc-outcome-btn[aria-pressed="true"][data-outcome="YES"] { background: var(--green); border-color: var(--green); color: var(--white); }
.cc-outcome-btn[aria-pressed="true"][data-outcome="NO"] { background: var(--red); border-color: var(--red); color: var(--white); }
.cc-outcome-btn[aria-pressed="true"][data-outcome="CALLBACK"] { background: var(--amber); border-color: var(--amber); color: var(--white); }
.cc-outcome-btn[aria-pressed="true"][data-outcome="NO_ANSWER"] { background: var(--slate-500); border-color: var(--slate-500); color: var(--white); }
.cc-outcome-btn[aria-pressed="true"][data-outcome="WRONG_NUMBER"] { background: var(--navy-mid); border-color: var(--navy-mid); color: var(--white); }

.cc-callback-date { margin-top: 8px; }
.cc-callback-date input {
  width: 100%; min-height: var(--tap); border: 1px solid var(--slate-300); border-radius: var(--radius-sm);
  padding: 0 10px;
}
.cc-notes {
  width: 100%; margin-top: 8px; border: 1px solid var(--slate-300); border-radius: var(--radius-sm);
  padding: 8px 10px; min-height: 56px; resize: vertical; font-size: 13.5px;
}
.cc-retry-btn {
  min-height: var(--tap); margin-top: 6px; width: 100%; background: var(--red); color: var(--white);
  border: none; border-radius: var(--radius-sm); font-weight: 700;
}

.load-more-btn {
  width: 100%; min-height: var(--tap); margin-top: 12px;
  background: var(--white); border: 1px solid var(--slate-300); border-radius: var(--radius-sm);
  font-weight: 700; color: var(--navy); box-shadow: var(--shadow);
}

/* -------------------------------- Email / WA ------------------------------ */
.info-card {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px;
}
.info-card .headline { font-weight: 700; font-size: 15px; color: var(--navy); }
.info-card .sub { font-size: 13px; color: var(--slate-700); margin-top: 4px; }
.wide-bar-track { height: 12px; border-radius: 999px; background: var(--slate-200); margin-top: 10px; overflow: hidden; display: flex; }
.wide-bar-track .seg-sent { background: var(--green); }
.wide-bar-track .seg-err { background: var(--red); }
.legend-row { display: flex; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--slate-700); flex-wrap: wrap; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; }
.error-rows { margin-top: 10px; border-top: 1px solid var(--slate-200); padding-top: 8px; }
.error-row { font-size: 12.5px; padding: 4px 0; color: var(--red); }
.wa-todo {
  background: var(--red-bg); border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 10px;
}
.wa-todo .t { font-weight: 700; color: var(--red); font-size: 13px; }
.wa-todo-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 8px; }
.wa-sent-list { margin-top: 8px; }
.wa-sent-row { font-size: 12.5px; display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--slate-100); }
.show-all-toggle {
  min-height: var(--tap); margin-top: 8px; width: 100%; background: var(--slate-100); border: none;
  border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 700; color: var(--slate-700);
}

/* ------------------------------------ Footer ------------------------------ */
.app-footer {
  text-align: center; padding: 16px 12px 28px; color: var(--slate-500); font-size: 12.5px;
}
.app-footer button {
  display: inline-block; margin-top: 6px; min-height: var(--tap); padding: 0 16px;
  background: var(--white); border: 1px solid var(--slate-300); border-radius: var(--radius-sm);
  font-weight: 700; color: var(--navy);
}

/* ------------------------------------ Loading ------------------------------ */
.loading-screen {
  position: fixed; inset: 0; background: var(--navy-deep); color: var(--white);
  display: flex; align-items: center; justify-content: center; font-size: 14px; z-index: 200;
}

@media (min-width: 480px) {
  main { padding: 16px 16px 32px; }
  .hero-number { font-size: 72px; }
}
