*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background:
    linear-gradient(180deg, rgba(91,142,240,0.07) 0%, rgba(8,10,12,0) 360px),
    #080A0C;
  color: #A8B4C4;
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
input, button { font-family: inherit; }

.logo { font-size: 1.1rem; font-weight: 700; color: #EDF2F7; letter-spacing: 0; }
.logo span { color: #5B8EF0; }

.btn-primary { background: #5B8EF0; color: #fff; border: none; padding: 9px 20px; border-radius: 6px; font-size: 0.88rem; font-weight: 600; cursor: pointer; transition: background 200ms; }
.btn-primary:hover { background: #3A6BD4; }
.btn-ghost { background: none; border: 1px solid #1E242C; color: #A8B4C4; padding: 9px 20px; border-radius: 6px; font-size: 0.88rem; cursor: pointer; transition: border-color 200ms, color 200ms; }
.btn-ghost:hover { border-color: #6B7A8F; color: #EDF2F7; }
.btn-danger { background: none; border: 1px solid #4A1010; color: #f87171; padding: 5px 12px; border-radius: 4px; font-size: 0.78rem; cursor: pointer; transition: background 200ms; }
.btn-danger:hover { background: rgba(248,113,113,0.1); }
.btn-sm { padding: 5px 12px; font-size: 0.78rem; border-radius: 4px; }

.card { background: #13171D; border: 1px solid #1E242C; border-radius: 12px; padding: 24px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 0.8rem; font-weight: 500; color: #6B7A8F; }
.field input { background: #0E1115; border: 1px solid #1E242C; border-radius: 6px; color: #EDF2F7; padding: 9px 12px; font-size: 0.9rem; outline: none; transition: border-color 200ms; }
.field input:focus { border-color: #5B8EF0; }
.field-row { display: flex; gap: 16px; }
.field-row .field { flex: 1; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.error-msg { color: #f87171; font-size: 0.82rem; margin-bottom: 12px; }

/* Login */
#login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { width: 100%; max-width: 380px; padding: 0 24px; }
.login-box h1 { font-size: 1.4rem; color: #EDF2F7; margin: 24px 0 28px; }

/* Auth card — unified with MagicBrief / MagicOps */
.auth-card {
  background: linear-gradient(180deg, #151A22 0%, #0D1117 100%);
  border: 1px solid #1E242C;
  border-radius: 10px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 14px 36px rgba(0,0,0,0.34);
}
.auth-logo {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0;
  color: #F0F4FF;
  margin: 0 0 4px;
}
.auth-logo span { color: #5B8EF0; }
.auth-title {
  font-size: 1rem;
  font-weight: 600;
  color: #EDF2F7;
  margin: 14px 0 6px;
}
.auth-sub {
  font-size: 0.8rem;
  color: #6B7A99;
  margin: 0 0 28px;
}
.field-hint {
  font-size: 0.7rem;
  font-weight: 400;
  color: #6B7A99;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 4px;
}
/* Voluntary change-password cancel: subdued secondary under the submit button. */
.cp-cancel-btn {
  width: 100%;
  margin-top: 8px;
  padding: 9px;
  background: transparent;
  color: #8B97AB;
  border: 1px solid #1E242C;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: color 150ms, border-color 150ms;
}
.cp-cancel-btn:hover { color: #EDF2F7; border-color: #2A323E; }
/* Self-service "Change My Password" in the users panel — denser than the
   page-wide btn-primary so it fits the row actions slot. */
.user-actions .user-self-change-btn {
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: 6px;
  font-weight: 600;
  border: none;
  color: #fff;
  background: #5B8EF0;
  cursor: pointer;
  transition: background 160ms;
}
.user-actions .user-self-change-btn:hover { background: #3A6BD4; }
.auth-card .field { margin-bottom: 16px; }
.auth-card .field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: #6B7A99;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.auth-card .field input {
  width: 100%;
  background: #080A0C;
  border: 1px solid #1E242C;
  border-radius: 6px;
  color: #F0F4FF;
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
}
.auth-card .field input:focus { border-color: #5B8EF0; }
.auth-card .field input::placeholder { color: #6B7A99; opacity: 0.7; }
.btn-submit {
  width: 100%;
  margin-top: 8px;
  padding: 11px;
  background: #5B8EF0;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-submit:hover { opacity: 0.88; }
.btn-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.login-note {
  margin-top: 16px;
  font-size: 13px;
  color: #9ca3af;
  text-align: center;
  cursor: default;
  transition: color 0.15s;
}
.login-note:hover { color: #F0F4FF; }
.login-note a {
  color: #CFE0FF;
  text-decoration: none;
}
.sso-primary {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 11px;
  background: #5B8EF0;
  color: #fff !important;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  transition: opacity 0.15s;
}
.sso-primary:hover { opacity: 0.88; }
.sso-helper {
  display: block;
  margin-top: 14px;
  color: #8B97AB;
  line-height: 1.5;
}
.local-fallback-link {
  display: inline-block;
  margin-top: 12px;
  color: #6B7A99 !important;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.local-fallback-link:hover { color: #CFE0FF !important; }

/* Topnav */
.topnav { display: flex; align-items: center; justify-content: space-between; padding: 16px 32px; border-bottom: 1px solid #1E242C; background: rgba(8,10,12,0.96); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 10; }

/* Content */
.content { max-width: 1100px; margin: 0 auto; padding: 32px; }

/* Events grid */
#events-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-top: 16px; }
.event-card { cursor: pointer; transition: border-color 200ms; }
.event-card:hover { border-color: #5B8EF0; }
.event-card h3 { font-size: 1rem; color: #EDF2F7; margin-bottom: 8px; }
.event-meta { font-size: 0.8rem; color: #6B7A8F; display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; }

/* Status badges */
.badge { display: inline-flex; align-items: center; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 8px; border-radius: 100px; }
.badge-DRAFT { background: rgba(251,191,36,0.1); color: #fbbf24; }
.badge-ACTIVE { background: rgba(52,211,153,0.1); color: #34d399; }
.badge-COMPLETED { background: rgba(100,116,139,0.1); color: #64748b; }
.badge-ARCHIVED { background: rgba(100,116,139,0.1); color: #64748b; }

/* Event detail */
#event-header { margin-bottom: 24px; }
#event-header h2 { font-size: 1.5rem; color: #EDF2F7; margin-bottom: 8px; }
#event-header .meta { font-size: 0.82rem; color: #6B7A8F; display: flex; gap: 20px; flex-wrap: wrap; margin-top: 12px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 768px) { .two-col { grid-template-columns: 1fr; } }

.section-title { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: #6B7A8F; margin-bottom: 12px; }

.inline-form { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.inline-form > input[type="text"] { flex: 1; min-width: 160px; background: #0E1115; border: 1px solid #1E242C; border-radius: 6px; color: #EDF2F7; padding: 8px 12px; font-size: 0.88rem; outline: none; }
.inline-form > input[type="text"]:focus { border-color: #5B8EF0; }

/* Compact file picker used inline inside .inline-form.
   The native <input type="file"> is hidden; a styled <span> acts as the
   visible button and a second <span> shows the chosen filename (or
   "optional" when nothing has been picked yet). No preview image — the
   task asked for a minimal add form; the filename is enough confirmation. */
.upload-pick { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.upload-pick input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-pick-btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; background: #1A1F27; border: 1px solid #2A3140; border-radius: 6px; color: #A8B4C4; font-size: 0.82rem; font-weight: 600; }
.upload-pick:hover .upload-pick-btn { border-color: #5B8EF0; color: #EDF2F7; }
.upload-pick-name { font-size: 0.78rem; color: #6B7A8F; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-hint { font-size: 0.74rem; color: #6B7A8F; margin: 6px 2px 12px; letter-spacing: 0.01em; }

.list-item { background: #13171D; border: 1px solid #1E242C; border-radius: 8px; padding: 12px 16px; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.list-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.list-copy { min-width: 0; }
.list-item-name { font-size: 0.9rem; color: #EDF2F7; }
.list-item-meta { font-size: 0.78rem; color: #6B7A8F; }
.list-sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.access-code { font-family: 'JetBrains Mono', monospace; background: rgba(91,142,240,0.1); color: #5B8EF0; padding: 2px 8px; border-radius: 4px; font-size: 0.82rem; letter-spacing: 0.08em; }
.judge-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.person-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(91,142,240,0.24);
  background: rgba(91,142,240,0.10);
  color: #5B8EF0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  font-size: 0.82rem;
  font-weight: 700;
}
.person-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mini-status {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.mini-status-ACTIVE { color: #34d399; background: rgba(52,211,153,0.10); border: 1px solid rgba(52,211,153,0.22); }
.mini-status-INACTIVE,
.mini-status-ELIMINATED { color: #8B97AB; background: rgba(107,122,143,0.10); border: 1px solid rgba(107,122,143,0.22); }
.mini-status-WINNER { color: #fbbf24; background: rgba(251,191,36,0.10); border: 1px solid rgba(251,191,36,0.24); }

.form-card { margin-bottom: 24px; }
.form-card h3 { font-size: 1rem; color: #EDF2F7; margin-bottom: 20px; }

/* Round management */
.rounds-section { margin-top: 24px; }
.round-bar { background: #13171D; border: 1px solid #1E242C; border-radius: 10px; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.round-bar-info { font-size: 0.9rem; color: #EDF2F7; }
.round-actions { display: flex; gap: 8px; }
#round-type { min-height: 44px; }
.score-grid { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 0.82rem; }
.score-grid th { background: #0E1115; color: #6B7A8F; padding: 8px 12px; text-align: left; border-bottom: 1px solid #1E242C; font-weight: 500; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; }
.score-grid td { padding: 8px 12px; border-bottom: 1px solid #0E1115; color: #A8B4C4; }
.score-grid tr:last-child td { border-bottom: none; }
.score-cell-high { color: #34d399; font-weight: 600; }
.score-cell-mid { color: #fbbf24; }
.score-cell-low { color: #f87171; }
.score-cell-empty { color: #4A5568; }
.results-list { margin-top: 12px; }
.result-row { display: flex; align-items: center; gap: 12px; background: #13171D; border: 1px solid #1E242C; border-radius: 8px; padding: 12px 16px; margin-bottom: 8px; }
.result-rank { font-size: 1.1rem; font-weight: 700; color: #6B7A8F; width: 34px; flex-shrink: 0; }
.result-main { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.result-copy { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; min-width: 0; }
.result-name { font-size: 0.95rem; color: #EDF2F7; overflow: hidden; text-overflow: ellipsis; }
.result-score { display: flex; flex-direction: column; align-items: flex-end; margin-right: 8px; }
.result-score .score-primary { font-size: 1.1rem; font-weight: 700; color: #5B8EF0; line-height: 1; }
.result-score .score-secondary { font-size: 0.75rem; color: #6B7A8F; margin-top: 3px; }
.badge-PENDING { background: rgba(251,191,36,0.1); color: #fbbf24; }
.badge-ADVANCED { background: rgba(52,211,153,0.1); color: #34d399; }
.badge-ELIMINATED { background: rgba(248,113,113,0.1); color: #f87171; }
.badge-WINNER { background: rgba(251,191,36,0.15); color: #fbbf24; }
.next-action-banner { border-radius: 10px; padding: 14px 18px; margin-top: 16px; font-size: 0.9rem; font-weight: 500; }
.banner-create { background: rgba(91,142,240,0.1); border: 1px solid rgba(91,142,240,0.2); color: #5B8EF0; }
.banner-winner { background: rgba(251,191,36,0.1); border: 1px solid rgba(251,191,36,0.2); color: #fbbf24; }
.banner-tie { background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.2); color: #f87171; }
.banner-manual { background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.2); color: #f87171; }
.missing-scores { font-size: 0.8rem; color: #f87171; margin-top: 8px; padding: 10px 14px; background: rgba(248,113,113,0.06); border-radius: 8px; }

/* Judge score breakdown */
.breakdown-wrap { margin-top: 20px; border: 1px solid #1E242C; border-radius: 10px; overflow: hidden; }
.breakdown-toggle {
  width: 100%; display: flex; align-items: center; gap: 8px;
  background: #0E1115; border: none; color: #A8B4C4;
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  min-height: 44px; padding: 12px 16px; cursor: pointer; text-align: left;
  transition: background 150ms, color 150ms;
}
.breakdown-toggle:hover { background: #13171D; color: #EDF2F7; }
.breakdown-arrow { font-size: 0.65rem; color: #4A5568; transition: color 150ms; }
.breakdown-toggle:hover .breakdown-arrow { color: #6B7A8F; }
.breakdown-body { border-top: 1px solid #1E242C; }
.breakdown-loading { font-size: 0.82rem; color: #6B7A8F; padding: 16px; }
.breakdown-scroll { overflow-x: auto; }
.breakdown-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.8rem; min-width: 480px;
}
.breakdown-table thead tr { background: #080A0C; }
.breakdown-table th {
  padding: 9px 14px; text-align: left;
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: #4A5568; border-bottom: 1px solid #1E242C; white-space: nowrap;
}
.breakdown-table td { padding: 9px 14px; border-bottom: 1px solid #0E1115; }
.breakdown-table tbody tr:last-child td { border-bottom: none; }
.breakdown-table tbody tr:hover td { background: rgba(255,255,255,0.02); }
.breakdown-name { color: #EDF2F7; font-weight: 500; white-space: nowrap; }
.bd-mid { color: #A8B4C4; text-align: center; }
.bd-high { color: #34d399; font-weight: 700; text-align: center; }
.bd-low  { color: #f87171; font-weight: 700; text-align: center; }
.bd-missing { color: #2D3748; text-align: center; }
.bd-total { color: #5B8EF0; font-weight: 700; text-align: right; border-left: 1px solid #1E242C; }
.bd-avg { color: #6B7A8F; font-size: 0.75rem; text-align: right; }

.scoreboard-bar { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.scoreboard-url { flex: 1; min-width: 200px; background: #0E1115; border: 1px solid #1E242C; border-radius: 6px; color: #6B7A8F; font-size: 0.78rem; padding: 7px 10px; font-family: 'JetBrains Mono', monospace; cursor: text; outline: none; }
.scoreboard-url:focus { border-color: #5B8EF0; color: #A8B4C4; }
.scoreboard-actions { display: flex; gap: 8px; flex-shrink: 0; }
.scoreboard-warning { margin-top: 8px; font-size: 0.78rem; color: #fbbf24; background: rgba(251,191,36,0.07); border: 1px solid rgba(251,191,36,0.15); border-radius: 6px; padding: 6px 12px; }
/* Public voting share row — parallel treatment to .scoreboard-bar above.
   When the event's publicVotingOpen is false, mute the URL input so the
   operator sees at a glance that the link they'd share isn't currently live. */
.public-vote-bar { margin-top: 10px; }
.public-vote-bar.is-off .scoreboard-url { color: #4A5568; background: #0B0D11; border-color: #161B22; }
.public-vote-bar.is-off .scoreboard-url:focus { color: #8B97AB; }

/* Judge Access share row — same shape as .scoreboard-bar / .public-vote-bar.
   There is no ON/OFF state (auth is via access code, not a kill switch) so
   we only need the spacing override to match the other rows. */
.judge-bar { margin-top: 10px; }

/* Neutral muted helper note under a share row. Companion to .scoreboard-warning
   but without the warning color — used for informational hints like
   "Judges will enter their access code to join this event". */
.scoreboard-hint { margin-top: 8px; font-size: 0.78rem; color: #6B7A8F; background: rgba(107,122,143,0.06); border: 1px solid rgba(107,122,143,0.15); border-radius: 6px; padding: 6px 12px; }

.danger-zone { margin-top: 40px; padding-top: 24px; border-top: 1px solid #2D1515; }
.danger-zone-title { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: #4A1010; margin-bottom: 12px; }
.btn-danger-full { background: none; border: 1px solid #7F1D1D; color: #f87171; min-height: 44px; padding: 10px 20px; border-radius: 6px; font-size: 0.88rem; font-weight: 600; cursor: pointer; transition: background 200ms, border-color 200ms; width: 100%; }
.btn-danger-full:hover { background: rgba(248,113,113,0.08); border-color: #f87171; }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.75); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-box { background: #13171D; border: 1px solid #1E242C; border-radius: 14px; padding: 28px; max-width: 440px; width: 100%; }
.modal-box h3 { font-size: 1rem; color: #EDF2F7; margin-bottom: 12px; }
.modal-box p { font-size: 0.85rem; color: #6B7A8F; margin-bottom: 20px; line-height: 1.6; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.badge-INVALIDATED { background: rgba(100,116,139,0.1); color: #64748b; text-decoration: line-through; }
.btn-amber { background: none; border: 1px solid #78350F; color: #fbbf24; padding: 5px 12px; border-radius: 4px; font-size: 0.78rem; cursor: pointer; transition: background 200ms; }
.btn-amber:hover { background: rgba(251,191,36,0.1); }
.round-bar.invalidated { opacity: 0.5; }
.round-bar.invalidated .round-bar-info { text-decoration: line-through; }

/* === Phase C: client layer === */
.topnav-actions { display: flex; gap: 10px; align-items: center; }
.topnav-user { font-size: 0.78rem; color: #6B7A8F; letter-spacing: 0.02em; }
.topnav-user strong { color: #A8B4C4; font-weight: 600; }

#clients-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
/* Premium client card: layered depth via subtle gradient + outer ring,
   accent gradient edge on hover, clear 3-row hierarchy (name+status / metric
   body / slug+arrow footer). Matches the MagicBrief / MagicOps visual tier. */
.client-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #141921 0%, #10141B 100%);
  border: 1px solid #1F2630;
  border-radius: 14px;
  padding: 18px 20px 16px;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(255,255,255,0.02) inset, 0 2px 6px rgba(0,0,0,0.25);
  transition: border-color 180ms ease, transform 160ms ease, box-shadow 200ms ease;
}
.client-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(91,142,240,0), rgba(91,142,240,0) 60%, rgba(91,142,240,0));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  transition: background 220ms ease;
}
.client-card:hover {
  border-color: rgba(91,142,240,0.55);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.38), 0 0 0 1px rgba(91,142,240,0.10);
}
.client-card:hover::before {
  background: linear-gradient(135deg, rgba(91,142,240,0.55), rgba(91,142,240,0.05) 55%, rgba(91,142,240,0));
}
.client-card:active { transform: translateY(-1px); }

.client-card .client-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.client-card .client-name {
  font-size: 1.05rem;
  color: #F0F4FF;
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  word-break: break-word;
}
.client-card .client-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #34d399;
  background: rgba(52,211,153,0.08);
  border: 1px solid rgba(52,211,153,0.28);
  flex-shrink: 0;
}
.client-card .client-status.inactive {
  color: #8B97AB;
  background: rgba(107,122,143,0.08);
  border-color: rgba(107,122,143,0.28);
}
.client-card .client-status .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #34d399;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(52,211,153,0.18);
}
.client-card .client-status.inactive .dot {
  background: #6B7A8F;
  box-shadow: 0 0 0 2px rgba(107,122,143,0.18);
}

.client-card .client-card-body {
  margin: 14px 0 14px;
}
.client-card .client-event-count {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.client-card .client-event-num {
  font-size: 1.6rem;
  font-weight: 700;
  color: #EDF2F7;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.client-card .client-event-label {
  font-size: 0.78rem;
  color: #6B7A8F;
  font-weight: 500;
}

.client-card .client-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid rgba(107,122,143,0.10);
}
.client-card .client-slug {
  font-family: 'JetBrains Mono', monospace;
  color: #5B6781;
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.client-card .client-arrow {
  font-size: 0.95rem;
  color: #4A5568;
  transition: color 180ms ease, transform 220ms ease;
  flex-shrink: 0;
  margin-left: 12px;
}
.client-card:hover .client-arrow {
  color: #5B8EF0;
  transform: translateX(3px);
}

#event-list-title { color: #A8B4C4; font-weight: 600; letter-spacing: 0.02em; }
#event-list-title .client-chip { display: inline-block; margin-left: 8px; background: rgba(91,142,240,0.1); border: 1px solid rgba(91,142,240,0.3); color: #5B8EF0; padding: 2px 10px; border-radius: 12px; font-size: 0.7rem; font-family: 'JetBrains Mono', monospace; }

/* === Phase C polish === */
.btn-disabled,
button.btn-primary:disabled,
button:disabled.btn-primary {
  opacity: 0.45;
  cursor: not-allowed;
  background: #1E242C;
  color: #6B7A8F;
  border-color: #1E242C;
}
.btn-disabled:hover { background: #1E242C; }

.create-helper {
  font-size: 0.78rem;
  color: #fbbf24;
  background: rgba(251,191,36,0.06);
  border: 1px solid rgba(251,191,36,0.18);
  border-radius: 6px;
  padding: 8px 14px;
  margin-bottom: 14px;
  letter-spacing: 0.01em;
}

.event-client-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  font-family: 'JetBrains Mono', monospace;
  background: rgba(91,142,240,0.1);
  border: 1px solid rgba(91,142,240,0.3);
  color: #5B8EF0;
  vertical-align: middle;
}
.event-client-badge.unassigned {
  background: rgba(107,122,143,0.08);
  border-color: rgba(107,122,143,0.25);
  color: #6B7A8F;
}

/* ---- SUPER_ADMIN users panel (password reset surface) ---- */
.users-panel { margin-top: 16px; }
#users-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(107,122,143,0.18);
  border-radius: 10px;
  background: linear-gradient(180deg, #151A22 0%, #11151C 100%);
}
.user-demo-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(91,142,240,0.35);
  background:
    radial-gradient(circle at 30% 20%, rgba(91,142,240,0.35), transparent 45%),
    linear-gradient(135deg, rgba(52,211,153,0.14), rgba(91,142,240,0.16));
  color: #DCE8FF;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  box-shadow: inset 0 0 20px rgba(91,142,240,0.08);
}
.user-main { min-width: 0; flex: 1; }
.user-email { font-weight: 600; color: #EDF2F7; font-size: 0.95rem; word-break: break-word; }
.user-meta { color: #6B7A8F; font-size: 0.82rem; margin-top: 2px; }
.user-flag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  background: rgba(240,165,0,0.12);
  color: #fbbf24;
  border: 1px solid rgba(240,165,0,0.35);
  font-family: 'JetBrains Mono', monospace;
}
.user-actions { display: flex; justify-content: flex-end; }
.user-actions button { font-size: 0.82rem; min-height: 38px; }
/* Scope chip: "Global" for SUPER_ADMIN (null clientId) / client name for CLIENT_ADMIN */
.user-scope {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid rgba(107,122,143,0.25);
  color: #8B97AB;
  background: rgba(107,122,143,0.08);
}
.user-scope-global {
  color: #5B8EF0;
  background: rgba(91,142,240,0.10);
  border-color: rgba(91,142,240,0.35);
}
.user-scope-client {
  color: #34d399;
  background: rgba(52,211,153,0.10);
  border-color: rgba(52,211,153,0.35);
}

/* ---- Reset-password modal ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.72);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-card {
  background: linear-gradient(180deg, #151A22 0%, #11151C 100%);
  border-radius: 14px;
  padding: 24px;
  width: 100%; max-width: 480px;
  box-shadow: 0 18px 48px rgba(0,0,0,0.38);
  border: 1px solid #1E242C;
}
.modal-title { margin: 0 0 4px; color: #EDF2F7; }
.modal-sub { margin: 0 0 14px; color: #6B7A8F; font-size: 0.9rem; }
.modal-warn {
  background: rgba(240,165,0,0.1);
  border: 1px solid rgba(240,165,0,0.35);
  color: #fbbf24;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.4;
  margin-bottom: 14px;
}
.modal-code-wrap {
  display: flex; gap: 8px; align-items: stretch;
  margin-bottom: 16px;
}
.modal-code {
  flex: 1;
  display: block;
  padding: 12px 14px;
  background: #080A0C;
  border: 1px solid #1E242C;
  border-radius: 8px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 1rem;
  letter-spacing: 0.02em;
  color: #EDF2F7;
  word-break: break-all;
  user-select: all;
}
.btn-copy { min-width: 78px; }
.modal-actions { display: flex; justify-content: flex-end; }

@media (max-width: 720px) {
  body { overflow-x: hidden; }

  #mc-widget {
    display: none !important;
  }

  .auth-card {
    max-width: 100%;
    padding: 30px 22px;
    border-radius: 8px;
  }

  .login-note {
    cursor: default;
    line-height: 1.45;
  }

  .login-note a {
    display: inline-block;
    color: #5B8EF0;
    font-weight: 600;
    white-space: nowrap;
  }

  .topnav {
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    flex-wrap: wrap;
  }

  .topnav-actions {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }

  .topnav-actions .btn-primary,
  .topnav-actions .btn-ghost,
  .topnav > .btn-ghost {
    min-height: 44px;
    padding: 10px 14px;
  }

  .topnav-user {
    width: 100%;
    line-height: 1.35;
  }

  .content {
    width: 100%;
    padding: 22px 16px 32px;
  }

  .card {
    padding: 18px;
    border-radius: 8px;
  }

  #clients-grid,
  #events-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .client-card {
    min-height: 142px;
    padding: 16px;
    border-radius: 8px;
  }

  .client-card .client-card-top,
  .list-item,
  .round-bar,
  .result-row,
  .user-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .result-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .result-main,
  .result-score {
    width: 100%;
  }

  .result-score {
    grid-column: 2;
    align-items: flex-start;
    margin-right: 0;
  }

  .list-main {
    width: 100%;
  }

  .client-card .client-status,
  .user-actions,
  .judge-actions,
  .round-actions {
    width: 100%;
  }

  .judge-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .client-card .client-card-foot {
    gap: 10px;
  }

  .client-card .client-slug {
    min-width: 0;
  }

  .event-meta,
  #event-header .meta {
    gap: 8px 12px;
  }

  #event-header h2 {
    font-size: 1.25rem;
    line-height: 1.25;
  }

  #event-header .btn-sm {
    width: 100%;
    min-height: 44px;
    border-radius: 8px;
  }

  .field-row,
  .form-actions,
  .modal-actions,
  .scoreboard-actions {
    flex-direction: column;
  }

  .form-actions .btn-primary,
  .form-actions .btn-ghost,
  .modal-actions .btn-primary,
  .modal-actions .btn-ghost,
  .list-item > button,
  .round-actions button,
  .user-actions button,
  .judge-actions button,
  .scoreboard-actions button {
    width: 100%;
    min-height: 44px;
  }

  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-form > input[type="text"],
  .inline-form .btn-primary,
  .upload-pick {
    width: 100%;
    min-width: 0;
  }

  .inline-form > input[type="text"],
  .inline-form .btn-primary {
    min-height: 44px;
  }

  .upload-pick {
    justify-content: space-between;
    gap: 12px;
  }

  .upload-pick-btn {
    min-height: 40px;
    align-items: center;
  }

  .upload-pick-name {
    max-width: 52%;
  }

  .scoreboard-bar {
    align-items: stretch;
    gap: 8px;
  }

  .scoreboard-url {
    flex: 0 0 100%;
    width: 100%;
    min-width: 0;
    min-height: 42px;
  }

  .scoreboard-actions {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }

  .scoreboard-actions button {
    min-width: 0;
    white-space: normal;
    line-height: 1.15;
  }

  .score-grid,
  .breakdown-table {
    min-width: 560px;
  }

  #score-grid-wrap,
  #results-wrap,
  .breakdown-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-card,
  .modal-box {
    padding: 20px;
    border-radius: 8px;
  }

  .modal-code-wrap {
    flex-direction: column;
  }
}

@media (max-width: 420px) {
  .auth-logo {
    font-size: 1.35rem;
  }

  .logo {
    font-size: 1rem;
  }

  .section-title {
    letter-spacing: 0.08em;
  }

  .btn-primary,
  .btn-ghost,
  .btn-submit {
    width: 100%;
  }
}
