/* Quiz Pro Duo — Admin Portal Styles (functional baseline) */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body { font-family: system-ui, -apple-system, sans-serif; background: #f5f5f5; color: #333; }

/* Nav */
.admin-nav {
  background: #1a1a2e; color: #fff; padding: 0.75rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-brand { color: #e8c547; font-weight: 700; font-size: 1.1rem; text-decoration: none; }
.nav-links a { color: #ccc; text-decoration: none; margin-left: 1.5rem; font-size: 0.9rem; }
.nav-links a:hover { color: #fff; }

/* Layout */
.admin-main { max-width: 1100px; margin: 2rem auto; padding: 0 1.5rem; }

/* Alerts */
.alert { padding: 0.75rem 1rem; border-radius: 4px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger  { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }

/* Buttons */
.btn {
  display: inline-block; padding: 0.5rem 1.2rem; border-radius: 4px;
  text-decoration: none; font-size: 0.9rem; cursor: pointer;
  border: none; transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary  { background: #e8c547; color: #1a1a2e; font-weight: 600; }
.btn-secondary{ background: #6c757d; color: #fff; }
.btn-link     { background: transparent; color: #4a90e2; padding: 0.5rem 0; }

/* Login */
.login-container {
  max-width: 380px; margin: 5rem auto; background: #fff;
  padding: 2.5rem; border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}
.login-container h1 { color: #e8c547; margin-bottom: 0.25rem; }
.login-container h2 { color: #555; font-weight: 400; margin-bottom: 2rem; font-size: 1rem; }

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.4rem; font-size: 0.85rem; color: #555; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 0.6rem 0.8rem; border: 1px solid #ddd;
  border-radius: 4px; font-size: 0.95rem;
}
.form-group input:focus { outline: none; border-color: #e8c547; box-shadow: 0 0 0 2px rgba(232,197,71,0.2); }
.form-actions { margin-top: 1.5rem; display: flex; gap: 0.75rem; align-items: center; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: 0.9rem; }
.data-table th { background: #1a1a2e; color: #fff; padding: 0.6rem 0.8rem; text-align: left; }
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { background: #2a2a4e; }
.data-table th.sort-asc::after  { content: " ▲"; font-size: 0.7em; opacity: 0.8; }
.data-table th.sort-desc::after { content: " ▼"; font-size: 0.7em; opacity: 0.8; }
.data-table td { padding: 0.6rem 0.8rem; border-bottom: 1px solid #eee; }
.data-table tr:hover td { background: #fafafa; }
.data-table a { color: #4a90e2; text-decoration: none; }

/* Filter bar */
.filter-bar { display: flex; flex-wrap: wrap; gap: 1rem; margin: 1rem 0 0.5rem; }
.filter-group { display: flex; align-items: center; gap: 0.5rem; }
.filter-group label { font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
                      color: #666; white-space: nowrap; }
.btn-toggle-group { display: flex; border: 1px solid #ddd; border-radius: 6px; overflow: hidden; }
.btn-toggle {
  padding: 0.3rem 0.75rem; font-size: 0.82rem; text-decoration: none;
  color: #444; background: #fff; border-right: 1px solid #ddd; white-space: nowrap;
}
.btn-toggle:last-child { border-right: none; }
.btn-toggle:hover { background: #f5f5f5; }
.btn-toggle.active { background: #1a1a2e; color: #fff; }

.filter-select {
  padding: 0.3rem 0.6rem; font-size: 0.82rem;
  border: 1px solid #ddd; border-radius: 6px;
  background: #fff; color: #444; cursor: pointer;
}

.results-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 0.5rem; }
.results-count { font-size: 0.82rem; color: #888; }
.no-results { color: #888; font-style: italic; margin-top: 1rem; }

/* Dashboard */
.dashboard-actions { display: flex; gap: 0.75rem; margin-bottom: 2rem; }
section { margin-top: 2rem; }
h2 { font-size: 1.1rem; color: #333; margin-bottom: 0.75rem; border-bottom: 2px solid #e8c547; padding-bottom: 0.3rem; }
dl { display: grid; grid-template-columns: 150px 1fr; gap: 0.5rem 1rem; font-size: 0.9rem; }
dt { font-weight: 600; color: #555; }
.action-bar { display: flex; gap: 0.75rem; margin-bottom: 1.5rem; }

/* ------------------------------------------------------------------ */
/* Event detail                                                        */
/* ------------------------------------------------------------------ */

.event-detail-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 1.25rem;
}
.event-status-badge {
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; padding: 0.3em 0.8em; border-radius: 20px;
}
.status-setup     { background: #e9ecef; color: #666; }
.status-live      { background: #d4edda; color: #155724; }
.status-finalized { background: #cce5ff; color: #004085; }

.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem;
  margin-bottom: 1.5rem;
}
.detail-card {
  background: #fff; border: 1px solid #e0e0e0; border-radius: 8px;
  padding: 1.25rem;
}
.detail-card h2 {
  display: flex; align-items: center; gap: 0.75rem;
  font-size: 0.9rem; margin-bottom: 0.75rem;
}
.detail-dl {
  display: grid; grid-template-columns: 110px 1fr;
  gap: 0.4rem 0.75rem; font-size: 0.88rem; margin-bottom: 1rem;
}
.detail-dl dt { font-weight: 600; color: #777; }
.detail-dl dd { color: #333; }

.state-controls { display: flex; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.btn-live { background: #28a745; color: #fff; }
.btn-live:hover { opacity: 0.85; }
.btn-live:disabled { background: #ccc; cursor: not-allowed; }

.payment-badge {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  padding: 0.2em 0.6em; border-radius: 20px;
}
.payment-unpaid   { background: #f8d7da; color: #721c24; }
.payment-paid     { background: #d4edda; color: #155724; }
.payment-no-charge{ background: #e2d9f3; color: #4a2f7a; }

.payment-form { margin-top: 0.75rem; }
.payment-form .form-row { gap: 0.75rem; }
.payment-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; align-items: center; }

.page-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-header h1 { margin: 0; }
.stat-chip {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  padding: 0.2em 0.7em; border-radius: 20px;
  background: #e2d9f3; color: #4a2f7a;
}

.section-header {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 0.5rem;
}
.section-header h2 { margin-bottom: 0; border-bottom: none; padding-bottom: 0; }
.btn-section-link { font-size: 0.85rem; color: #4a90e2; text-decoration: none; }
.btn-section-link:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ */
/* Shared table/list helpers                                           */
/* ------------------------------------------------------------------ */

.count-badge {
  display: inline-block; background: #e8c547; color: #1a1a2e;
  font-size: 0.75rem; font-weight: 700; padding: 0.1em 0.5em;
  border-radius: 20px; margin-left: 0.5rem; vertical-align: middle;
}
.row-actions { white-space: nowrap; }
.row-actions a { color: #4a90e2; text-decoration: none; margin-right: 0.75rem; font-size: 0.85rem; }
.btn-link-danger {
  background: none; border: none; color: #dc3545; cursor: pointer;
  font-size: 0.85rem; padding: 0; text-decoration: none;
}
.btn-link-danger:hover { text-decoration: underline; }
.muted-action { color: #ccc; font-size: 0.85rem; cursor: not-allowed; }
.round-num-cell { font-family: monospace; font-weight: 700; }
.vis-yes { color: #28a745; font-weight: 700; }
.vis-no  { color: #dc3545; }
.type-badge {
  display: inline-block; font-size: 0.75rem; padding: 0.15em 0.5em;
  border-radius: 3px; background: #eee; color: #555;
}
.type-badge.type-audio   { background: #d4edda; color: #155724; }
.type-badge.type-video   { background: #cce5ff; color: #004085; }
.type-badge.type-images  { background: #fff3cd; color: #856404; }
.type-badge.type-spoken  { background: #f8f9fa; color: #333; }
.type-badge.type-wall    { background: #e2d9f3; color: #4a2c8f; }
.type-badge.type-table   { background: #fde2e2; color: #7b1d1d; }

/* Drag-and-drop rounds */
.col-drag  { width: 28px; padding-right: 0 !important; }
.col-num   { width: 36px; }
.drag-handle {
  cursor: grab; color: #ccc; font-size: 1.1rem; display: block;
  text-align: center; user-select: none; line-height: 1;
}
.drag-handle:hover { color: #999; }
tr.dragging { opacity: 0.4; background: #fffbea; }
tr[draggable=true]:hover .drag-handle { color: #666; }
.drag-hint { font-size: 0.8rem; color: #888; }
#save-status.saving { color: #888; }
#save-status.saved  { color: #28a745; font-weight: 600; }
#save-status.error  { color: #dc3545; font-weight: 600; }

.empty-state {
  text-align: center; padding: 3rem 1rem; color: #888;
}
.empty-state p { margin-bottom: 1rem; font-size: 1rem; }

/* Forms */
.standard-form { max-width: 620px; }
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }
.form-group-sm { flex: 0 0 120px !important; }
.form-group-lg { flex: 2 !important; }
.form-group-check { display: flex; flex-direction: column; justify-content: flex-end; }
.checkbox-label { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.checkbox-label input[type=checkbox] { width: auto; }
.field-hint { font-size: 0.75rem; color: #aaa; margin-top: 0.2rem; display: block; }
.optional { font-size: 0.8em; color: #aaa; font-weight: 400; }
textarea { width: 100%; padding: 0.6rem 0.8rem; border: 1px solid #ddd; border-radius: 4px; font-size: 0.9rem; resize: vertical; }

/* ------------------------------------------------------------------ */
/* Leaderboard                                                          */
/* ------------------------------------------------------------------ */

.leaderboard-wrap { overflow-x: auto; }
.leaderboard-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.leaderboard-table thead th {
  background: #1a1a2e; color: #fff; padding: 0.6rem 0.8rem; text-align: left;
  position: sticky; top: 0;
}
.leaderboard-table td { padding: 0.55rem 0.8rem; border-bottom: 1px solid #eee; }
.leaderboard-table tr:hover td { background: #fafafa; }

.col-rank  { width: 50px; text-align: center; }
.col-total { font-weight: 700; font-size: 1.05rem; color: #1a1a2e; }
.col-rounds { color: #888; font-size: 0.8rem; }
.col-round  { text-align: center; color: #555; font-size: 0.82rem; }
.no-score   { color: #ddd; }

.rank-1 td { background: #fffbea; }
.rank-2 td { background: #f8f8f8; }
.rank-3 td { background: #fff5f0; }

.lb-note { font-size: 0.8rem; color: #aaa; margin-top: 0.75rem; }

/* ------------------------------------------------------------------ */
/* Player portal admin setup                                           */
/* ------------------------------------------------------------------ */

.portal-inactive { max-width: 540px; }
.portal-inactive p { color: #555; margin-bottom: 0.75rem; font-size: 0.95rem; }
.portal-options {
  display: flex; flex-direction: column; gap: 0.5rem;
  margin: 1rem 0; padding: 1rem; background: #f8f9fa;
  border-radius: 6px; border: 1px solid #e0e0e0;
}

.portal-active-grid {
  display: grid; grid-template-columns: 280px 1fr; gap: 1.5rem;
  align-items: start;
}
.portal-qr-card, .portal-settings-card {
  background: #fff; border: 1px solid #e0e0e0;
  border-radius: 8px; padding: 1.25rem;
}
.portal-status-bar {
  display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem;
}
.portal-active-badge {
  background: #d4edda; color: #155724; font-size: 0.72rem;
  font-weight: 700; text-transform: uppercase; padding: 0.2em 0.6em;
  border-radius: 20px;
}
.portal-code {
  font-family: monospace; font-size: 1.1rem; font-weight: 700;
  letter-spacing: 0.1em; color: #1a1a2e;
}
.portal-qr-img {
  display: block; width: 100%; max-width: 240px;
  margin: 0 auto 1rem; image-rendering: pixelated;
}
.portal-url {
  text-align: center; font-size: 0.8rem; word-break: break-all;
  margin-bottom: 1rem;
}
.portal-url a { color: #4a90e2; }
.portal-qr-actions {
  display: flex; flex-direction: column; gap: 0.5rem; align-items: center;
}

.reg-toggle-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem; background: #f8f9fa; border-radius: 6px;
  margin-bottom: 1.25rem;
}
.reg-status { font-size: 0.8rem; font-weight: 700; margin-left: 0.5rem; }
.reg-open   { color: #28a745; }
.reg-closed { color: #dc3545; }
.portal-settings-form { margin-top: 0; }

/* ------------------------------------------------------------------ */
/* Scoring interface                                                    */
/* ------------------------------------------------------------------ */

.scoring-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 1.25rem;
}
.scoring-date { font-size: 0.85rem; color: #888; }

.scoring-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  align-items: start;
}

/* --- Entry panel --- */
.scoring-entry { display: flex; flex-direction: column; gap: 1rem; }

.round-selector { display: flex; align-items: center; gap: 0.75rem; font-size: 0.85rem; }
.round-selector select {
  padding: 0.4rem 0.6rem; border: 1px solid #ddd; border-radius: 4px;
  font-size: 0.85rem; flex: 1;
}

.scan-area label {
  display: block; font-weight: 700; font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.05em; color: #888; margin-bottom: 0.4rem;
}
#scan-input {
  width: 100%; padding: 0.9rem 1rem; font-size: 1.2rem; font-family: monospace;
  border: 2px solid #1a1a2e; border-radius: 6px; background: #fff;
  transition: border-color 0.15s;
}
#scan-input:focus { outline: none; border-color: #e8c547; box-shadow: 0 0 0 3px rgba(232,197,71,0.2); }
.scan-hint { font-size: 0.75rem; color: #aaa; margin-top: 0.3rem; display: block; }
.scan-hint code { background: #f0f0f0; padding: 0.1em 0.3em; border-radius: 3px; }

/* Confirm card */
.confirm-card {
  background: #fff; border: 2px solid #e8c547; border-radius: 8px;
  padding: 1.25rem; animation: slideIn 0.12s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.confirm-meta { display: flex; gap: 1rem; align-items: baseline; margin-bottom: 0.75rem; flex-wrap: wrap; }
.confirm-table { font-size: 0.85rem; background: #1a1a2e; color: #e8c547; padding: 0.2em 0.6em; border-radius: 4px; font-weight: 700; }
.confirm-team  { font-size: 1.1rem; font-weight: 700; color: #1a1a2e; }
.confirm-round { font-size: 0.85rem; color: #666; }

.confirm-score-row {
  display: flex; align-items: center; gap: 0.75rem;
}
.confirm-score-row label { font-weight: 600; font-size: 0.85rem; color: #555; white-space: nowrap; }
#score-input {
  width: 100px; padding: 0.6rem 0.75rem; font-size: 1.4rem; font-weight: 700;
  border: 2px solid #ddd; border-radius: 6px; text-align: center;
}
#score-input:focus { outline: none; border-color: #e8c547; }
.confirm-max { font-size: 0.9rem; color: #888; white-space: nowrap; }
#save-btn kbd {
  font-size: 0.7em; background: rgba(255,255,255,0.3);
  padding: 0.1em 0.3em; border-radius: 3px; margin-left: 0.3em;
}

.confirm-warning {
  margin-top: 0.75rem; padding: 0.5rem 0.75rem;
  background: #fff3cd; border: 1px solid #ffc107; border-radius: 4px;
  font-size: 0.85rem; color: #856404;
}

/* Error */
.scan-error {
  padding: 0.75rem 1rem; background: #f8d7da; border: 1px solid #f5c6cb;
  border-radius: 6px; color: #721c24; font-size: 0.9rem;
}

/* Recent entries */
.recent-entries h3 {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: #888; margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.75rem;
  border: none; padding: 0;
}
.btn-tiny {
  font-size: 0.72rem; padding: 0.15rem 0.5rem; background: #eee;
  border: 1px solid #ddd; border-radius: 3px; cursor: pointer; color: #666;
}
#recent-list { list-style: none; display: flex; flex-direction: column; gap: 0.3rem; }
#recent-list li {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.6rem; background: #f8f9fa; border-radius: 4px;
  font-size: 0.85rem;
}
#recent-list li.override { background: #fff3cd; }
.recent-empty { color: #aaa; font-style: italic; }
.r-table  { font-weight: 700; color: #1a1a2e; font-family: monospace; min-width: 32px; }
.r-team   { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-round  { color: #888; font-size: 0.8rem; }
.r-score  { font-weight: 700; color: #1a1a2e; }
.r-max    { font-weight: 400; color: #aaa; font-size: 0.8em; }
.r-tag    { font-size: 0.7rem; background: #ffc107; color: #333; padding: 0.1em 0.4em; border-radius: 3px; }
.btn-undo {
  margin-left: auto; background: none; border: none; color: #ccc;
  cursor: pointer; font-size: 0.9rem; padding: 0.1rem 0.3rem;
  border-radius: 3px; flex-shrink: 0;
}
.btn-undo:hover { background: #fee; color: #c00; }

/* --- Tracker panel --- */
.scoring-tracker {
  background: #fff; border: 1px solid #e0e0e0; border-radius: 8px;
  overflow: hidden; position: sticky; top: 1rem;
}
.tracker-header {
  background: #1a1a2e; color: #fff; padding: 0.75rem 1rem;
  display: flex; justify-content: space-between; align-items: center;
}
.tracker-title { font-weight: 600; font-size: 0.9rem; }
.tracker-count { font-size: 0.85rem; color: #e8c547; font-weight: 700; }
.tracker-progress { padding: 0.5rem 1rem 0; }
.progress-bar { background: #eee; border-radius: 4px; height: 6px; overflow: hidden; }
.progress-fill { background: #e8c547; height: 100%; border-radius: 4px; transition: width 0.3s; }

.tracker-stats {
  display: flex; gap: 0.4rem; flex-wrap: wrap;
  padding: 0.5rem 0.75rem; background: #f9f9fb;
  border-bottom: 1px solid #eee;
}
.stat-chip {
  display: flex; flex-direction: column; align-items: center;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 5px;
  padding: 0.2rem 0.55rem; min-width: 3.4rem; flex: 1;
}
.stat-label {
  font-size: 0.62rem; font-weight: 700; color: #888;
  text-transform: uppercase; letter-spacing: 0.04em; line-height: 1.2;
}
.stat-val {
  font-size: 0.88rem; font-weight: 700; color: #1a1a2e; line-height: 1.4;
}

.tracker-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.tracker-table thead th {
  background: #f5f5f5; padding: 0.4rem 0.75rem; text-align: left;
  font-size: 0.75rem; color: #888; font-weight: 600; text-transform: uppercase;
}
.tracker-table td { padding: 0.35rem 0.75rem; border-bottom: 1px solid #f0f0f0; }
.tracker-empty { text-align: center; color: #ccc; padding: 1.5rem; }
.scored-row td  { color: #333; }
.scored-row .t-score { font-weight: 700; color: #1a1a2e; }
.pending-row td { color: #bbb; }
.outstanding    { font-size: 1.2em; color: #ddd; }
.t-num          { font-family: monospace; font-weight: 700; width: 32px; }
.just-saved     { background: #fffbea; }


/* --- Table QR codes --- */
.table-qr-section {
  margin-top: 2rem; background: #fff; border: 1px solid #e0e0e0;
  border-radius: 8px; padding: 1.5rem;
}
.table-qr-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.5rem;
}
.table-qr-header h2 { font-size: 1.1rem; color: #1a1a2e; }
.table-qr-note { font-size: 0.85rem; color: #888; margin-bottom: 1.25rem; }
.table-qr-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1.25rem;
}
.table-qr-card {
  text-align: center; border: 1px solid #e0e0e0; border-radius: 6px; padding: 0.75rem;
  background: #fafafa;
}
.table-qr-img { width: 100%; max-width: 120px; height: auto; display: block; margin: 0 auto 0.5rem; }
.table-qr-label { font-weight: 700; font-size: 0.9rem; color: #1a1a2e; }

@media print {
  .admin-nav, .action-bar, .portal-settings-card, .portal-qr-actions,
  .reg-toggle-bar, .alert, .table-qr-header .btn { display: none !important; }
  .table-qr-section { border: none; padding: 0; margin: 0; }
  .table-qr-grid { grid-template-columns: repeat(4, 1fr); gap: 0.75rem; }
  .table-qr-card { break-inside: avoid; border: 1px solid #ccc; }
}

/* --- Live Event Control Panel --- */
.live-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.75rem;
}
.live-title    { font-size: 1.5rem; color: #1a1a2e; margin-bottom: 0.15rem; }
.live-subtitle { font-size: 0.9rem; color: #888; }
.live-header-right { display: flex; align-items: center; gap: 1rem; }
.live-teams-badge {
  background: #1a1a2e; color: #e8c547; font-weight: 700;
  padding: 0.35rem 0.85rem; border-radius: 20px; font-size: 0.9rem;
}
.live-empty { color: #888; font-style: italic; margin: 2rem 0; }

.live-round-list { display: flex; flex-direction: column; gap: 1rem; }

.live-round-card {
  background: #fff; border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border-left: 6px solid #ccc;
  overflow: hidden;
}
.live-round-card.status-not_started { border-left-color: #ccc; }
.live-round-card.status-open        { border-left-color: #28a745; }
.live-round-card.status-closed      { border-left-color: #fd7e14; }
.live-round-card.status-scored      { border-left-color: #4a90e2; }
.live-round-card.status-revealed    { border-left-color: #e8c547; }

.lrc-top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.25rem 0.5rem;
}
.lrc-identity { display: flex; align-items: center; gap: 0.75rem; }
.lrc-num  { font-size: 1.6rem; font-weight: 700; color: #1a1a2e; line-height: 1; min-width: 2rem; }
.lrc-name { font-size: 1rem; font-weight: 600; color: #1a1a2e; }
.lrc-pts  { font-size: 0.8rem; color: #888; }

.lrc-status-badge {
  font-size: 0.75rem; font-weight: 700; padding: 0.3rem 0.75rem;
  border-radius: 20px; text-transform: uppercase; letter-spacing: 0.04em;
  background: #f0f0f0; color: #666;
}
.status-open     .lrc-status-badge { background: #d4edda; color: #155724; }
.status-closed   .lrc-status-badge { background: #ffe5cc; color: #7a3c00; }
.status-scored   .lrc-status-badge { background: #cce5ff; color: #004085; }
.status-revealed .lrc-status-badge { background: #fff3cd; color: #856404; }

.lrc-bottom {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.75rem 1.25rem 1rem; flex-wrap: wrap; gap: 0.5rem;
}
.lrc-submissions { font-size: 0.9rem; color: #666; }
.subs-count { font-weight: 700; font-size: 1.1rem; color: #1a1a2e; }
.lrc-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.lrc-done { font-size: 0.9rem; color: #28a745; font-weight: 600; }

.btn-live-action {
  padding: 0.6rem 1.4rem; font-size: 0.95rem; font-weight: 600;
  border-radius: 6px; border: none; cursor: pointer;
  transition: opacity 0.15s; text-decoration: none; display: inline-block;
}
.btn-live-action:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-open   { background: #28a745; color: #fff; }
.btn-close  { background: #fd7e14; color: #fff; }
.btn-score  { background: #4a90e2; color: #fff; }
.btn-reveal { background: #e8c547; color: #1a1a2e; }
.btn-live   { background: #28a745; color: #fff; }
.btn-live-action:hover { opacity: 0.88; }

@media (max-width: 480px) {
  .lrc-bottom { flex-direction: column; align-items: flex-start; }
  .btn-live-action { width: 100%; text-align: center; padding: 0.75rem; }
}

/* --- Round answers review --- */
.answers-meta { color: #888; font-size: 0.9rem; margin-bottom: 1.25rem; }
.answer-section { margin-bottom: 1.75rem; }
.answer-section-header {
  display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap;
  background: #f5f5f5; border-left: 4px solid #e8c547;
  padding: 0.6rem 1rem; border-radius: 0 4px 4px 0; margin-bottom: 0.5rem;
}
.q-num  { font-weight: 700; color: #1a1a2e; font-size: 0.9rem; white-space: nowrap; }
.q-text { font-size: 0.95rem; color: #333; flex: 1; }
.q-key  { font-size: 0.82rem; color: #666; white-space: nowrap; }
.answers-table .answer-cell { font-size: 0.95rem; }
.answers-table tr.no-answer td { color: #bbb; }
.raw-answer { font-size: 0.9rem; color: #444; padding: 0.15rem 0; }

/* ── Group History Dashboard ─────────────────────────────────────────────── */
.gh-page { max-width: 1100px; }

.gh-header {
  display: flex; align-items: flex-start; gap: 2rem;
  background: #1a1a2e; color: #fff;
  border-radius: 10px; padding: 1.5rem 2rem;
  margin-bottom: 2rem; flex-wrap: wrap;
}
.gh-eyebrow {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: #e8c547; margin-bottom: 0.25rem;
}
.gh-group-name { margin: 0; font-size: 2rem; color: #fff; line-height: 1.1; }
.gh-header-title { flex: 1; min-width: 200px; }
.gh-header-stats { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; }
.gh-stat { text-align: center; }
.gh-stat-value { display: block; font-size: 2rem; font-weight: 700; color: #e8c547; line-height: 1; }
.gh-stat-label { display: block; font-size: 0.72rem; text-transform: uppercase;
                 letter-spacing: 0.08em; color: #aaa; margin-top: 0.2rem; }
.gh-back { color: #aaa !important; align-self: flex-start; margin-left: auto; }

.gh-section { margin-bottom: 2.5rem; }
.gh-section-title {
  font-size: 1.15rem; font-weight: 700; color: #1a1a2e;
  border-bottom: 3px solid #e8c547; padding-bottom: 0.4rem;
  margin-bottom: 0.75rem; display: flex; align-items: baseline; gap: 0.75rem;
}
.gh-section-sub { font-size: 0.8rem; font-weight: 400; color: #888; }

.gh-winner-name { font-weight: 600; color: #1a1a2e; }
.gh-row-unscored td { color: #aaa; font-style: italic; }
.gh-row-champion td { background: #fffbea; }
.gh-medal-cell { font-size: 1.1rem; width: 2rem; text-align: center; }
.gh-team-name { font-weight: 600; }
.muted { color: #bbb; }

/* ── Invoice / receipt action strip ─────────────────────────────────────── */
.invoice-actions {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: #f8f9fa;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}
.invoice-actions-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.invoice-actions-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
  flex: 1;
}
.invoice-email-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.invoice-email-form input[type="email"] {
  flex: 1;
  padding: 0.3rem 0.6rem;
  font-size: 0.875rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  color: #1a1a2e;
}
.btn-sm {
  padding: 0.3rem 0.75rem;
  font-size: 0.82rem;
}

/* ── Event form section dividers ────────────────────────────── */
.form-divider { border: none; border-top: 1px solid #e5e7eb; margin: 1.5rem 0 1rem; }
.form-section-title { font-size: 1rem; font-weight: 600; color: #1a1a2e; margin: 0 0 0.25rem; }
.form-section-hint { font-size: 0.83rem; color: #888; margin: 0 0 1rem; }

/* ── Inline field locking ────────────────────────────────────────────────── */
.form-inline-banner {
  background: #f0f9ff; border: 1px solid #bae6fd; color: #0c4a6e;
  font-size: 0.85rem; padding: 0.6rem 1rem; border-radius: 6px;
  margin-bottom: 1.25rem;
}
input.field-locked {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  cursor: pointer;
  color: #1a1a2e;
  transition: background 0.12s, border-color 0.12s;
}
input.field-locked:hover {
  background: #f8fafc !important;
  border-color: #d1d5db !important;
}
input.field-locked::placeholder { color: #bbb; }
input.field-editing {
  background: #fff !important;
  border-color: #e8c547 !important;
  box-shadow: 0 0 0 2px rgba(232,197,71,0.25) !important;
  cursor: text;
}
/* Save button pulse when fields have been changed */
.btn-dirty {
  box-shadow: 0 0 0 3px rgba(232,197,71,0.4);
  animation: dirty-pulse 1.8s ease-in-out infinite;
}
@keyframes dirty-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(232,197,71,0.4); }
  50%       { box-shadow: 0 0 0 6px rgba(232,197,71,0.15); }
}

/* ── Dashboard ───────────────────────────────────────────────────────────── */
.dash-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem;
}
.dash-header h1 { margin: 0; font-size: 1.75rem; color: #1a1a2e; }
.dash-welcome { font-size: 0.9rem; color: #6b7280; display: block; margin-top: 0.2rem; }

/* summary chips */
.dash-chips { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 2rem; }
.dash-chip {
  display: flex; flex-direction: column; align-items: center;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 0.75rem 1.25rem; text-decoration: none; min-width: 90px;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.dash-chip:hover { border-color: #2563eb; box-shadow: 0 2px 8px rgba(37,99,235,.12); }
.chip-num { font-size: 1.6rem; font-weight: 700; color: #1a1a2e; line-height: 1; }
.chip-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: #6b7280; margin-top: 0.25rem; }
.chip-warn .chip-num { color: #dc2626; }
.chip-warn { border-color: #fca5a5; background: #fff5f5; }
.chip-muted .chip-num { color: #6b7280; }
.badge-warn {
  display: inline-block; background: #dc2626; color: #fff;
  font-size: 0.7rem; font-weight: 700; padding: 0 0.4rem; border-radius: 10px;
  vertical-align: middle; margin-left: 0.3rem; line-height: 1.5;
}

/* quick-nav grid */
.dash-nav-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem; margin-bottom: 2.5rem;
}
.dash-nav-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 1.1rem 1.25rem; display: flex; gap: 0.85rem; align-items: flex-start;
}
.dash-nav-icon svg {
  width: 22px; height: 22px; flex-shrink: 0;
  color: #2563eb; margin-top: 0.15rem;
}
.dash-nav-body h3 { font-size: 0.95rem; font-weight: 700; color: #1a1a2e; margin: 0 0 0.5rem; }
.dash-nav-links { display: flex; flex-direction: column; gap: 0.3rem; }
.dash-nav-links a { font-size: 0.83rem; color: #2563eb; text-decoration: none; }
.dash-nav-links a:hover { text-decoration: underline; }
.dash-nav-more { color: #6b7280 !important; font-style: italic; }

/* section headers */
.dash-section { margin-bottom: 2.5rem; }
.dash-section-header {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 0.75rem; border-bottom: 2px solid #e5e7eb; padding-bottom: 0.4rem;
}
.dash-section-header h2 { font-size: 1.1rem; color: #1a1a2e; margin: 0; }

/* upcoming event rows */
.dash-event-list { display: flex; flex-direction: column; gap: 0.6rem; }
.dash-event-row {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 0.85rem 1.1rem;
  display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center;
}
.dash-event-live { border-left: 4px solid #dc2626; }
.dash-event-meta { flex: 1; min-width: 180px; }
.dash-event-date { font-size: 0.75rem; font-weight: 700; color: #2563eb; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 0.15rem; }
.dash-event-name { font-size: 0.95rem; font-weight: 600; color: #1a1a2e; }
.dash-event-name a { color: inherit; text-decoration: none; }
.dash-event-name a:hover { text-decoration: underline; }
.dash-event-venue { font-size: 0.8rem; color: #6b7280; margin-top: 0.1rem; }
.badge-unconfirmed {
  display: inline-block; background: #fff3cd; color: #856404;
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  padding: 0.1rem 0.5rem; border-radius: 4px; margin-left: 0.4rem; vertical-align: middle;
}
.dash-event-stats { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.dash-stat-pill {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.78rem; font-weight: 600; color: #374151;
  background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 20px;
  padding: 0.2rem 0.6rem;
}
.dash-stat-pill svg { width: 14px; height: 14px; flex-shrink: 0; }
.pill-empty { color: #9ca3af; background: #fafafa; }
.pill-portal { color: #065f46; background: #d1fae5; border-color: #6ee7b7; }
.dash-event-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.btn-live { background: #dc2626; color: #fff; font-weight: 600; }
.btn-live:hover { opacity: 0.88; }

/* group grid */
.dash-group-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem;
}
.dash-group-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 1rem 1.1rem;
}
.dash-group-name { font-size: 0.95rem; font-weight: 700; color: #1a1a2e; margin-bottom: 0.35rem; }
.dash-group-counts { font-size: 0.82rem; color: #6b7280; margin-bottom: 0.6rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.count-upcoming { color: #2563eb; font-weight: 600; }
.dash-group-links { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.dash-group-links a { font-size: 0.8rem; color: #2563eb; text-decoration: none; }
.dash-group-links a:hover { text-decoration: underline; }

/* ── Groups page ─────────────────────────────────────────────────────────── */
.groups-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem;
  margin-top: 1.5rem;
}
.group-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 1.1rem 1.25rem;
}
.group-card-name { font-size: 1.05rem; font-weight: 700; color: #1a1a2e; margin-bottom: 0.5rem; }
.group-card-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem 0.75rem;
  font-size: 0.82rem; color: #6b7280; margin-bottom: 0.75rem;
}
.group-card-stats strong { color: #1a1a2e; }
.group-card-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.25rem; }

/* ── Analytics: big-number chips ─────────────────────────────────────────── */
.an-chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.an-chip {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 1rem 1.25rem;
}
.an-chip-num {
  font-size: 2rem; font-weight: 700; color: #1a1a2e; line-height: 1;
}
.an-chip-label {
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: #6b7280; margin-top: 0.35rem; display: block;
}

/* ── Analytics: chart wrappers ───────────────────────────────────────────── */
.analytics-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 800px) { .analytics-grid-2 { grid-template-columns: 1fr; } }

.chart-wrap {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 1.1rem 1.25rem 1.25rem;
}
.chart-title {
  font-size: 0.9rem; font-weight: 700; color: #1a1a2e;
  margin: 0 0 0.85rem; text-transform: uppercase; letter-spacing: .04em;
}
.chart-canvas-wrap {
  position: relative; width: 100%;
}

/* ── Difficulty badges ────────────────────────────────────────────────────── */
.diff-badge {
  display: inline-block; padding: 0.15rem 0.55rem; border-radius: 4px;
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
.diff-easy   { background: #d1fae5; color: #065f46; }
.diff-medium { background: #fef3c7; color: #92400e; }
.diff-hard   { background: #fee2e2; color: #991b1b; }

/* ── Score matrix (event analytics pivot table) ──────────────────────────── */
.score-matrix { font-size: 0.82rem; }
.score-matrix th, .score-matrix td { padding: 0.4rem 0.5rem; white-space: nowrap; }
.score-cell-top  { background: #d1fae5; font-weight: 700; color: #065f46; }
.score-cell-low  { background: #fee2e2; color: #991b1b; }
.round-key-list {
  margin-top: 0.75rem; font-size: 0.78rem; color: #6b7280;
  display: flex; flex-wrap: wrap; gap: 0.3rem 1.25rem;
}
.round-key-list strong { color: #1a1a2e; }

/* ── Rounds library ──────────────────────────────────────────────────────── */
.rl-search-bar {
  display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center;
  margin-bottom: 1rem;
}
.rl-search-bar input, .rl-search-bar select {
  padding: 0.45rem 0.75rem; border: 1px solid #d1d5db; border-radius: 6px;
  font-size: 0.88rem; background: #fff;
}
.rl-search-bar input { flex: 1; min-width: 200px; }
.rl-search-bar select { min-width: 140px; }

.rl-detail-inner {
  background: #f8fafc; border-top: 1px solid #e5e7eb;
  padding: 0.75rem 1.25rem 1rem 2.5rem;
}
.rl-detail-table {
  width: 100%; border-collapse: collapse; font-size: 0.82rem;
}
.rl-detail-table th {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: #6b7280; padding: 0.25rem 0.6rem;
  border-bottom: 1px solid #e5e7eb; white-space: nowrap;
}
.rl-detail-table td {
  padding: 0.3rem 0.6rem; border-bottom: 1px solid #f0f2f5;
}
.rl-detail-table tr:last-child td { border-bottom: none; }
.rl-detail-table tr:hover td { background: #f0f9ff; }
