/* ============================================================
   HNÍ Scorecards — demo styles
   Mobile-first, big tap targets, calm pro look.
   ============================================================ */

/* The hidden attribute must always win over explicit display rules
   (e.g. .identity-bar sets display:flex, which would otherwise show
   through a `hidden` toggle). */
[hidden] { display: none !important; }

:root {
  --navy: #0b1d3a;
  --navy-2: #13294b;
  --red: #c8102e;
  --red-soft: #ffe1e6;
  --blue: #1f4cd6;
  --blue-soft: #dfe6ff;
  --ink: #1a1f2c;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f6f7fb;
  --card: #ffffff;
  --ok: #1f7a3a;
  --warn: #b45309;
  --gold: #b8860b;
  --olympic: #0e7490;      /* Olympic environment accent (teal) */
  --olympic-soft: #cffafe;
  --shadow: 0 1px 2px rgba(11,29,58,.05), 0 8px 24px rgba(11,29,58,.06);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 .4em; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: .95rem; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- Header ---------- */

.app-header {
  background: var(--navy);
  color: #fff;
  padding: 14px 20px;
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 16px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 12px rgba(0,0,0,.18);
  transition: box-shadow .2s;
}
/* Olympic environment: distinct accent so it's always clear where you are. */
body.mode-olympic .app-header { box-shadow: inset 0 -3px 0 var(--olympic), 0 2px 12px rgba(0,0,0,.18); }
body.mode-olympic .brand-mark { background: var(--olympic); }

/* ---------- Environment (discipline) switch ---------- */
.mode-switch {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,.06);
  padding: 4px;
  border-radius: 10px;
  justify-self: start;
}
.mode-btn {
  background: transparent;
  color: #cdd5e3;
  border: none;
  padding: 8px 14px;
  font: inherit; font-weight: 700; font-size: .85rem;
  border-radius: 8px;
  cursor: pointer;
  min-height: 40px;
  transition: background .15s, color .15s;
}
.mode-btn:hover { color: #fff; }
.mode-btn[aria-pressed="true"] { background: #fff; color: var(--navy); }
body.mode-olympic .mode-btn[aria-pressed="true"] { color: var(--olympic); }

.olympic-soon { text-align: center; padding: 40px 28px; }
.olympic-soon h2 { margin-bottom: 8px; }
.olympic-soon p { max-width: 520px; margin: 0 auto; }

/* External scoreboard (second screen) */
.scoreboard {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--navy); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 4vh 4vw; text-align: center;
}
.scoreboard.blank { background: #000; }
.scoreboard.idle .sb-idle {
  font-family: 'Bebas Neue', sans-serif; font-size: 7vw; letter-spacing: .05em;
  display: flex; flex-direction: column; gap: 1.5vh;
}
.sb-idle span { font-family: 'Inter', sans-serif; font-size: 2.4vw; opacity: .55; letter-spacing: 0; }
.sb-round {
  font-family: 'Bebas Neue', sans-serif; font-size: 5.5vw; letter-spacing: .06em;
  color: #cdd5e3; margin-bottom: 3vh;
}
.sb-corners { display: grid; grid-template-columns: 1fr 1fr; gap: 5vw; width: 92vw; margin-bottom: 4vh; }
.sb-corner {
  font-weight: 800; font-size: 3.4vw; padding: 1.6vh 0; border-radius: 14px; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-corner.sb-red  { background: var(--red); }
.sb-corner.sb-blue { background: var(--blue); }
.sb-judges { display: flex; flex-direction: column; gap: 2.2vh; width: 72vw; }
.sb-judge-row {
  display: grid; grid-template-columns: 1fr 2.5ch 1.2ch 2.5ch; align-items: center; gap: 3vw;
  font-family: 'Bebas Neue', sans-serif; font-size: 7vw; line-height: 1;
}
.sb-jn { font-family: 'Inter', sans-serif; font-weight: 700; font-size: 3vw; color: #9fb0c9; text-align: left; }
.sb-score { text-align: center; }
.sb-score.sb-num-red  { color: #ff7a8a; }
.sb-score.sb-num-blue { color: #7ea2ff; }
.sb-dash { color: #64748b; text-align: center; }
.sb-wait { font-family: 'Inter', sans-serif; font-size: 2.4vw; opacity: .6; }

/* Result banner */
.sb-winner {
  display: flex; align-items: center; justify-content: center; gap: 1.5vw;
  width: 92vw; margin-bottom: 4vh; padding: 2vh 2vw; border-radius: 16px;
  font-family: 'Bebas Neue', sans-serif;
}
.sb-winner.sb-win-red  { background: var(--red); }
.sb-winner.sb-win-blue { background: var(--blue); }
.sb-winner.sb-win-draw { background: #334155; }
.sb-win-label { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 2vw; letter-spacing: .12em; opacity: .85; }
.sb-win-name  { font-size: 4.5vw; letter-spacing: .02em; }
.sb-win-split { font-size: 4vw; opacity: .9; margin-left: auto; padding-left: 2vw; }
.sb-win-draw .sb-win-split { margin-left: 1.5vw; }
/* Dim the losing corner's score on the result view */
.sb-pick-red  .sb-num-blue,
.sb-pick-blue .sb-num-red { opacity: .5; }

.toolbar-sep { display: inline-block; width: 1px; height: 22px; background: var(--line); margin: 0 4px; vertical-align: middle; }

/* Overview dashboard */
.overview-filters { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.overview-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .overview-cols { grid-template-columns: 1fr; } }

/* Win/Loss/Draw badges (olympic fighter record) */
.result-badge { font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.result-badge.result-win  { background: #dcfce7; color: #166534; }
.result-badge.result-loss { background: #fee2e2; color: #991b1b; }
.result-badge.result-draw { background: #e5e7eb; color: #374151; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.6rem;
  background: var(--red);
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: .04em;
}
.brand-text strong { display: block; font-size: 1.05rem; line-height: 1; }
.brand-text em { font-style: normal; font-size: .8rem; opacity: .72; }

.tabs {
  display: flex;
  gap: 6px;
  background: rgba(255,255,255,.06);
  padding: 4px;
  border-radius: 10px;
  justify-self: center;
}
.tab {
  background: transparent;
  color: #cdd5e3;
  border: none;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, color .15s;
  min-height: 44px;
}
.tab:hover { color: #fff; }
.tab[aria-selected="true"] { background: #fff; color: var(--navy); }

.reset-btn {
  background: transparent;
  color: #cdd5e3;
  border: 1px solid rgba(255,255,255,.18);
  padding: 8px 14px;
  border-radius: 8px;
  font: inherit; font-weight: 500; font-size: .85rem;
  cursor: pointer;
  min-height: 40px;
}
.reset-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

/* ---------- Main / pages ---------- */

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

.page-head { margin-bottom: 20px; }
.page-head h1 { margin-bottom: 4px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  border: 1px solid var(--line);
}

/* ---------- Identity bar ---------- */

.identity-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: linear-gradient(135deg, #fff 0%, #f3f5fb 100%);
  border: 1px solid var(--line);
  border-left: 4px solid var(--navy);
  border-radius: 12px;
  padding: 14px 20px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.identity-info {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.identity-label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
.identity-name { font-weight: 700; font-size: 1.1rem; color: var(--navy); }
.identity-slot {
  background: var(--navy);
  color: #fff;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
}
.identity-slot.empty { background: var(--muted); }

.identity-picker { margin-bottom: 22px; }
.identity-picker h2 { margin-bottom: 4px; }

/* ---------- Form ---------- */

.form-section {
  border: none;
  padding: 0;
  margin: 0 0 28px;
}
.form-section legend {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 12px;
  padding: 0;
  color: var(--navy);
}

.row { display: grid; gap: 14px; margin-bottom: 14px; }
.row.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .row.two { grid-template-columns: 1fr; } }

label > span {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}

select, input[type="date"], input[type="text"], input[type="number"] {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  min-height: 48px;
  transition: border-color .15s, box-shadow .15s;
}
select:focus, input:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(11,29,58,.12);
}

.new-bout-fields {
  background: #f9fafb;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-top: 10px;
}

/* ---------- Bout corners bar (in scoring) ---------- */

.bout-corners-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}
@media (max-width: 640px) { .bout-corners-bar { grid-template-columns: 1fr; } }

.corner-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}
.corner-chip.corner-red { border-top: 3px solid var(--red); }
.corner-chip.corner-blue { border-top: 3px solid var(--blue); }
.corner-dot {
  width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex-shrink: 0;
}
.dot-red { background: var(--red); }
.dot-blue { background: var(--blue); }
.corner-info { display: flex; flex-direction: column; gap: 2px; }
.corner-info strong { font-size: 1rem; }

.diploma-badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: .02em;
}
.diploma-badge.has    { background: #fff4d6; color: var(--gold); }
.diploma-badge.no     { background: #eef0f6; color: var(--muted); }
.diploma-badge.empty  { background: transparent; color: var(--muted); font-style: italic; }

/* ---------- Rounds grid (new scoring layout) ---------- */

.rounds-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 22px;
}
.round-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.1fr) 1fr 1fr auto;
  gap: 12px;
  align-items: stretch;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
.send-round-cell { display: flex; align-items: center; }
.send-round-btn { white-space: nowrap; height: 100%; }
.send-round-btn.sent { background: var(--ok); color: #fff; border-color: var(--ok); }
@media (max-width: 640px) {
  .round-row { grid-template-columns: 1fr 1fr; }
  .round-label { grid-column: 1 / -1; }
  .send-round-cell { grid-column: 1 / -1; }
  .send-round-btn { width: 100%; }
}
.round-label {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-right: 10px;
  border-right: 1px solid var(--line);
}
@media (max-width: 640px) {
  .round-label { border-right: none; border-bottom: 1px solid var(--line); padding-right: 0; padding-bottom: 8px; }
}
.round-label strong {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.4rem;
  letter-spacing: .04em;
  line-height: 1;
  color: var(--navy);
}
.round-label .criterion {
  font-size: .9rem;
  font-weight: 600;
  color: var(--ink);
  margin-top: 2px;
}
.round-label .criterion-sub {
  font-size: .72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: 4px;
}

.score-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.score-cell .cell-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: .78rem;
  font-weight: 600;
}
.score-cell.red .cell-head { color: var(--red); }
.score-cell.blue .cell-head { color: var(--blue); }
.score-cell .cell-head .max-hint {
  color: var(--muted);
  font-weight: 500;
  font-size: .72rem;
}
.score-cell input[type="number"] {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-height: 56px;
  padding: 8px 10px;
}
.score-cell input[type="number"]::-webkit-outer-spin-button,
.score-cell input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.score-cell input.over-max {
  border-color: var(--red);
  background: #fff5f6;
}

/* ---------- Penalty pair ---------- */

.penalties-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 22px;
}
@media (max-width: 900px) { .penalties-pair { grid-template-columns: 1fr; } }
.corner-pen {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
.corner-pen.corner-red { border-top: 3px solid var(--red); }
.corner-pen.corner-blue { border-top: 3px solid var(--blue); }
.corner-pen h4 { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }

.penalties {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.penalties .check {
  display: flex; align-items: center; gap: 8px;
  font-size: .9rem;
  cursor: pointer;
  min-height: 44px;
}
.penalties .penalty-sep {
  height: 1px;
  background: var(--line);
  margin: 4px 2px;
}
.penalties input[type="checkbox"] {
  width: 20px; height: 20px;
  accent-color: var(--navy);
}
.penalties .num { display: block; }
.penalties .num span {
  display: block;
  font-size: .7rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.penalties .num input { min-height: 40px; padding: 6px 8px; text-align: center; }

/* ---------- Card summary ---------- */

.card-summary {
  margin-top: 20px;
  padding: 18px;
  background: linear-gradient(135deg, #f9fafb 0%, #f3f5fb 100%);
  border-radius: 12px;
  text-align: center;
}
.summary-row {
  display: flex; justify-content: center; align-items: baseline; gap: 14px;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--muted);
}
.summary-row strong { font-size: 2rem; color: var(--navy); min-width: 60px; }
.summary-row .vs { font-size: 1.4rem; color: var(--muted); }

/* ---------- Form actions ---------- */

.form-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.btn {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  padding: 14px 24px;
  cursor: pointer;
  min-height: 52px;
  font-size: 1rem;
  transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-primary:disabled { background: var(--muted); cursor: not-allowed; }
.btn-link {
  background: transparent;
  color: var(--navy);
  text-decoration: underline;
  padding: 10px 14px;
  min-height: 44px;
}
.btn-link:hover { color: var(--navy-2); }

.form-msg { font-size: .9rem; }
.form-msg.ok { color: var(--ok); font-weight: 600; }
.form-msg.error { color: var(--red); font-weight: 600; }

/* ---------- Bouts list ---------- */

.bout-list { display: grid; gap: 14px; }
.bout-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color .15s, transform .05s;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
}
.bout-card:hover { border-color: var(--navy); }
.bout-card:active { transform: translateY(1px); }

.bout-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; font-size: .82rem; color: var(--muted); }
.bout-meta .chip {
  background: #eef0f6;
  color: var(--navy);
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: .75rem;
}
.bout-fight { font-size: 1.05rem; font-weight: 600; }
.bout-fight .vs { color: var(--muted); font-weight: 500; padding: 0 8px; }
.bout-fight .red { color: var(--red); }
.bout-fight .blue { color: var(--blue); }

.bout-result {
  text-align: right;
  font-size: .85rem;
}
.bout-total {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-size: 1.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.bout-total .red  { color: var(--red); }
.bout-total .blue { color: var(--blue); }
.bout-total .dash { color: var(--muted); font-weight: 500; font-size: 1.1rem; }
.bout-result .winner {
  font-weight: 700;
  font-size: 1rem;
  display: block;
}
.bout-result .winner.red { color: var(--red); }
.bout-result .winner.blue { color: var(--blue); }
.bout-result .winner.draw { color: var(--muted); }
.bout-result .score-split {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

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

.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(11,29,58,.55);
  backdrop-filter: blur(2px);
}
.modal-panel {
  position: relative;
  background: #fff;
  border-radius: var(--radius);
  max-width: 920px; width: calc(100% - 32px);
  max-height: 88vh; overflow-y: auto;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-close {
  position: absolute; top: 12px; right: 14px;
  background: transparent; border: none;
  font-size: 1.8rem; cursor: pointer; color: var(--muted);
  width: 40px; height: 40px;
  border-radius: 8px;
}
.modal-close:hover { background: #f1f2f6; color: var(--ink); }

.modal-bout-head { margin-bottom: 20px; }
.modal-bout-head h2 { margin-bottom: 8px; }

.judges-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 780px) { .judges-grid { grid-template-columns: 1fr; } }
.judge-card {
  background: #f9fafb;
  border-radius: 10px;
  padding: 14px;
  border: 1px solid var(--line);
}
.judge-card h4 { margin: 0 0 4px; font-size: .95rem; color: var(--navy); }
.judge-card .slot-label {
  font-size: .72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
  margin-bottom: 10px;
}
.judge-card .totals {
  display: flex; justify-content: space-between;
  font-size: .95rem;
  font-weight: 700;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  margin-top: 6px;
}
.judge-card .totals .red { color: var(--red); }
.judge-card .totals .blue { color: var(--blue); }
.judge-card table { width: 100%; font-size: .85rem; border-collapse: collapse; }
.judge-card td { padding: 4px 2px; }
.judge-card td.lbl { color: var(--muted); font-size: .78rem; }
.judge-card td.r { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.judge-card td.r .vs { color: var(--muted); padding: 0 4px; font-weight: 400; }

/* ---------- Stats ---------- */

.stats-tabs {
  display: inline-flex;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 20px;
}
.stats-tab {
  background: transparent;
  border: none;
  padding: 10px 22px;
  font: inherit; font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  color: var(--muted);
  min-height: 44px;
}
.stats-tab.active { background: var(--navy); color: #fff; }

.stats-panel { display: block; }
.stats-panel[hidden] { display: none; }

.picker {
  display: block;
  max-width: 420px;
  margin-bottom: 22px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-tile {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.stat-tile .label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin-bottom: 6px;
}
.stat-tile .value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.1;
}
.stat-tile .sub {
  font-size: .8rem;
  color: var(--muted);
  margin-top: 4px;
}

.stat-section { margin-top: 24px; }
.stat-section h2 { font-size: 1.05rem; margin-bottom: 10px; }

.mini-list {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.mini-list .row-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #f1f2f6;
}
.mini-list .row-item:last-child { border-bottom: none; }
.mini-list .row-item .date { font-size: .82rem; color: var(--muted); min-width: 90px; }
.mini-list .row-item .desc { font-weight: 500; }
.mini-list .row-item .result {
  font-weight: 700;
  font-size: .9rem;
  padding: 4px 10px;
  border-radius: 6px;
}
.mini-list .row-item .result.win { background: #e6f6ec; color: var(--ok); }
.mini-list .row-item .result.loss { background: #fee2e6; color: var(--red); }
.mini-list .row-item .result.draw { background: #f1f2f6; color: var(--muted); }

/* Judge per-club score breakdown */
.club-stats {
  display: grid;
  gap: 8px;
}
.club-stat-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.6fr) minmax(120px, 2fr) auto auto;
  gap: 14px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
}
.club-stat-row.below {
  border-left-color: var(--red);
  background: #fffafa;
}
.club-stat-name { font-weight: 500; font-size: .92rem; }
.club-stat-bar {
  height: 8px;
  background: #f1f2f6;
  border-radius: 999px;
  overflow: hidden;
}
.club-stat-fill {
  height: 100%;
  background: var(--navy);
  border-radius: 999px;
  transition: width .25s ease;
}
.club-stat-row.below .club-stat-fill { background: var(--red); }
.club-stat-value {
  font-weight: 700;
  font-size: 1rem;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.club-stat-meta {
  font-size: .78rem;
  color: var(--muted);
  white-space: nowrap;
}
.club-stat-row.is-selected {
  border-left-color: var(--navy);
  background: #f5f8ff;
}
@media (max-width: 640px) {
  .club-stat-row { grid-template-columns: 1fr auto; gap: 8px 12px; }
  .club-stat-bar { grid-column: 1 / -1; }
  .club-stat-meta { grid-column: 2; }
}

/* List search (Keppendur / Dómarar) */
.list-search { margin-bottom: 18px; }
.search-input {
  width: 100%;
  max-width: 420px;
  padding: 11px 14px;
  font-size: .95rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
.search-input:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(20, 33, 61, .12);
}

/* Stats controls (judge picker + season side by side) */
.stats-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-end;
}
.stats-controls .picker { margin-bottom: 22px; flex: 1 1 220px; }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 12px;
}

/* ---------- Fighters page ---------- */

.inline-check {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  min-height: 44px;
}
.inline-check input[type="checkbox"] {
  width: 22px; height: 22px;
  accent-color: var(--navy);
}
.inline-check span {
  font-weight: 500;
  font-size: .95rem;
  margin-bottom: 0;
}

#fighterForm { margin-bottom: 26px; }
#fighterForm h2 { margin-bottom: 16px; }

.fighters-by-club {
  display: grid;
  gap: 16px;
}
.club-section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.club-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: linear-gradient(135deg, #f9fafb 0%, #f3f5fb 100%);
  border-bottom: 1px solid var(--line);
}
.club-section-head h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--navy);
}
.club-section-head .count {
  font-size: .78rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.fighter-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid #f1f2f6;
}
.fighters-by-club .fighter-row { cursor: pointer; transition: background .12s; }
.fighters-by-club .fighter-row:hover { background: #f9fafb; }
.fighter-row:last-child { border-bottom: none; }
.fighter-row .fighter-main {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.fighter-row .fighter-main strong { font-size: 1rem; }
.fighter-row .fighter-meta {
  font-size: .78rem;
  color: var(--muted);
  margin-top: 2px;
}
.medal-tag {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  letter-spacing: .03em;
  white-space: nowrap;
}
.medal-diploma { background: #f1ead5; color: #6b5d3c; }
.medal-bronze  { background: #f3dcc4; color: #8a4d20; }
.medal-silver  { background: #e6e8eb; color: #4a5360; }
.medal-gold    { background: #fff4d6; color: #b8860b; }

.gender-tag,
.weight-tag {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  background: #eef0f6;
  color: var(--navy);
  letter-spacing: .03em;
}
.weight-tag {
  background: #eaf4ee;
  color: #1d6b3f;
}
.class-tag {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--olympic-soft);
  color: var(--olympic);
  letter-spacing: .03em;
}

.field-label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
}
.medal-checks {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.medal-check {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  gap: 10px;
  min-height: 48px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.medal-check:has(input:checked) {
  border-color: var(--navy);
  background: #f4f6fc;
}
.medal-check input[type="checkbox"] {
  width: 20px; height: 20px;
  accent-color: var(--navy);
  margin: 0;
}

.row-actions {
  display: flex;
  gap: 6px;
}
.btn-tiny {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--navy);
  font: inherit;
  font-weight: 600;
  font-size: .8rem;
  padding: 6px 12px;
  min-height: 36px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn-tiny:hover { background: #f1f2f6; }
.btn-tiny.btn-danger { color: var(--red); border-color: #fdd; }
.btn-tiny.btn-danger:hover { background: #fff5f6; border-color: var(--red); }
.btn-tiny.btn-add { color: #fff; background: var(--navy); border-color: var(--navy); }
.btn-tiny.btn-add:hover { background: var(--navy-2); color: #fff; }
.btn-tiny:disabled {
  color: var(--muted);
  cursor: not-allowed;
  background: transparent;
}
.btn-tiny:disabled:hover { background: transparent; }
.disabled-hint {
  font-size: .72rem;
  color: var(--muted);
  font-style: italic;
}

.empty-club {
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
  font-style: italic;
}

/* Judge list (same row style as fighters) */
.judge-list {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.judge-list .fighter-row:last-child { border-bottom: none; }

/* Tabs on small screens — horizontal scroll instead of wrap */
@media (max-width: 720px) {
  .app-header { grid-template-columns: 1fr; gap: 10px; }
  .tabs {
    justify-self: stretch;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .tab { white-space: nowrap; flex-shrink: 0; }
  .reset-btn { justify-self: end; }
}

/* ---------- Footer ---------- */

.app-footer {
  text-align: center;
  padding: 24px;
  font-size: .8rem;
  color: var(--muted);
}

/* ---------- Móts (events) page ---------- */

.mot-list {
  display: grid;
  gap: 16px;
}
.mot-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.mot-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #f9fafb 0%, #f3f5fb 100%);
  border-bottom: 1px solid var(--line);
}
.mot-info h3 {
  margin: 0 0 6px;
  font-size: 1.1rem;
  color: var(--navy);
}
.mot-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  font-size: .85rem;
  color: var(--muted);
}
.mot-bouts {
  padding: 0;
}
.mot-bout-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid #f1f2f6;
  cursor: pointer;
  transition: background .12s;
}
.mot-bout-row:last-child { border-bottom: none; }
.mot-bout-row:hover { background: #f9fafb; }
.mot-bout-row .bout-meta { margin-bottom: 4px; }
.mot-bout-row .bout-fight { font-size: 1rem; font-weight: 600; }
.mot-bout-row .bout-fight .vs { color: var(--muted); font-weight: 500; padding: 0 6px; }
.mot-bout-row .bout-fight .red { color: var(--red); }
.mot-bout-row .bout-fight .blue { color: var(--blue); }
.mot-bout-row .bout-result {
  text-align: right;
  font-size: .82rem;
}
.mot-bout-row .bout-result .winner {
  display: block;
  font-weight: 700;
  font-size: .9rem;
}
.mot-bout-row .bout-result .winner.red { color: var(--red); }
.mot-bout-row .bout-result .winner.blue { color: var(--blue); }
.mot-bout-row .bout-result .winner.draw { color: var(--muted); }
.mot-bout-row .bout-result .score-split {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

#motForm { margin-bottom: 24px; }
#motForm h2 { margin-bottom: 16px; }

/* ---------- Modal toolbar / audit / signatures ---------- */

.modal-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
  gap: 8px;
}

.card-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

.audit-tag {
  font-size: .72rem;
  color: var(--warn);
  font-weight: 600;
  font-style: italic;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

.print-only { display: none; }
.print-signatures {
  margin-top: 30px;
  page-break-inside: avoid;
}
.signature-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-top: 28px;
}
.signature-col {
  text-align: center;
  font-size: .82rem;
  color: #333;
}
.signature-col .signature-line {
  height: 1px;
  background: #000;
  margin-bottom: 6px;
  margin-top: 48px;
}

/* ---------- Print styles ---------- */
@media print {
  @page { margin: 14mm; }
  body:not(.print-overview) * { visibility: hidden; }
  body:not(.print-overview) #boutModal, body:not(.print-overview) #boutModal * { visibility: visible; }
  #boutModal {
    position: absolute;
    top: 0; left: 0; right: 0;
    width: 100%;
    height: auto;
    display: block !important;
  }
  .modal-backdrop, .modal-close, .no-print { display: none !important; }
  .modal-panel {
    box-shadow: none !important;
    max-height: none;
    overflow: visible;
    padding: 0;
    border-radius: 0;
    background: #fff;
    width: 100%;
    max-width: none;
  }
  .modal-bout-head h2 { font-size: 18pt; color: #000; }
  .judges-grid { display: grid !important; grid-template-columns: 1fr 1fr 1fr !important; gap: 10pt !important; }
  .judge-card {
    box-shadow: none !important;
    border: 1px solid #888 !important;
    background: #fff !important;
    page-break-inside: avoid;
  }
  .judge-card h4 { color: #000; }
  .print-only { display: block !important; }
  .bout-meta, .judges-grid, .print-signatures { page-break-inside: avoid; }
  .chip { background: #eee !important; color: #000 !important; border: 1px solid #888; }

  /* Overview printing (board reports) */
  body.print-overview .app-header,
  body.print-overview .app-footer,
  body.print-overview .overview-actions,
  body.print-overview .mode-switch { display: none !important; }
  body.print-overview main { padding: 0 !important; }
  body.print-overview .stat-tile,
  body.print-overview .stat-section,
  body.print-overview .club-stat-row,
  body.print-overview .overview-cols { page-break-inside: avoid; }
  body.print-overview .club-stat-fill { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* ============================================================
   Login screen
   ============================================================ */
.auth-screen[hidden],
.app-header[hidden],
.app-footer[hidden] { display: none !important; }

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(200,16,46,.18), transparent 60%),
    linear-gradient(160deg, var(--navy) 0%, #081427 100%);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 18px;
  padding: 30px 28px 26px;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-brand .brand-text strong { display: block; font-size: 1.05rem; line-height: 1; color: var(--ink); }
.auth-brand .brand-text em { font-style: normal; font-size: .8rem; color: var(--muted); }
.auth-card h1 { font-size: 1.5rem; margin-bottom: 4px; }
.auth-card label { display: block; margin: 16px 0 0; }
.auth-card .btn-primary { width: 100%; margin-top: 22px; }
.auth-card .form-msg { display: block; text-align: center; margin-top: 14px; min-height: 1.2em; }

/* ============================================================
   Header user area + role badge
   ============================================================ */
.header-user { display: flex; align-items: center; gap: 10px; justify-self: end; }
.user-chip { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; margin-right: 4px; }
.user-email { font-size: .8rem; color: #cdd5e3; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-badge {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  margin-top: 2px;
  background: rgba(255,255,255,.16);
  color: #fff;
}
.role-badge.role-admin { background: #1f7a3a; }
.role-badge.role-super_admin { background: var(--gold); }
.role-badge.role-admin_viewer { background: #475569; }
.role-badge.role-judge { background: var(--blue); }
.role-badge.role-supervisor { background: var(--olympic); }

@media (max-width: 900px) {
  .user-email { display: none; }
}

/* Read-only (Admin Viewer): hide all editing affordances */
body.role-viewer .tab[data-page="score"],
body.role-viewer #resetBtn,
body.role-viewer #fighterForm,
body.role-viewer #judgeForm,
body.role-viewer #motForm,
body.role-viewer .row-actions,
body.role-viewer .card-actions,
body.role-viewer .identity-bar { display: none !important; }

/* ============================================================
   Custom bardagi picker
   ============================================================ */
.bout-picker-field { margin-bottom: 14px; }
.bout-picker-field .field-label {
  display: block; font-size: .85rem; font-weight: 600; color: var(--ink); margin-bottom: 10px;
}
.bout-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.bout-pick-card {
  position: relative;
  text-align: left;
  font: inherit;
  cursor: pointer;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.bout-pick-card:hover { border-color: #c4ccda; box-shadow: var(--shadow); }
.bout-pick-card:active { transform: translateY(1px); }
.bout-pick-card.is-selected {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(11,29,58,.12);
}
.bout-pick-card .bpc-check {
  position: absolute;
  top: 10px; right: 12px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: .8rem;
  display: none;
  align-items: center;
  justify-content: center;
}
.bout-pick-card.is-selected .bpc-check { display: flex; }

.bpc-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bpc-date { font-size: .82rem; font-weight: 600; color: var(--ink); }
.bpc-mot { font-size: .78rem; color: var(--muted); }
.bout-pick-card .chip {
  font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: #eef1f6; color: var(--navy);
}

.bpc-fighters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bpc-corner { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: .98rem; }
.bpc-corner.red { color: var(--red); }
.bpc-corner.blue { color: var(--blue); }
.bpc-vs { color: var(--muted); font-weight: 500; font-size: .85rem; }

.bpc-progress { display: flex; align-items: center; gap: 8px; }
.bpc-pips { display: inline-flex; gap: 4px; }
.bpc-pips i {
  width: 18px; height: 6px; border-radius: 3px; background: var(--line); display: inline-block;
}
.bpc-pips i.on { background: var(--ok); }

/* "New bout" card */
.bout-pick-card.is-new {
  flex-direction: row;
  align-items: center;
  gap: 14px;
  background: #f9fbff;
  border-style: dashed;
  border-color: #c4ccda;
}
.bout-pick-card.is-new.is-selected { background: #eef3ff; border-style: solid; }
.bpc-plus {
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 11px;
  background: var(--navy); color: #fff;
  font-size: 1.6rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.bpc-new-text strong { display: block; font-size: 1rem; }

@media (max-width: 640px) {
  .bout-picker { grid-template-columns: 1fr; }
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  z-index: 300;
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--red); }
.toast.ok { background: var(--ok); }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
