:root {
  --ink: #0b0b0b;
  --ink-soft: #161616;
  --panel: rgba(255, 255, 255, 0.94);
  --sidebar: #111111;
  --green: #009246;
  --green-deep: #007a3a;
  --red: #ce2b37;
  --red-hot: #e03944;
  --white: #ffffff;
  --sand: #f4f4f1;
  --fog: #6e6e6e;
  --line: rgba(0, 0, 0, 0.08);
  --shadow: 0 24px 50px rgba(0, 0, 0, 0.28);
  --sidebar-w: 260px;
  --font-display: "Archivo Black", "Arial Black", sans-serif;
  --font-body: "Manrope", "Avenir Next", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.5;
  background: var(--ink);
  overflow: hidden;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(90deg, var(--green) 0 8px, transparent 8px),
    linear-gradient(90deg, transparent calc(100% - 8px), var(--red) 0),
    linear-gradient(165deg, #101010 0%, #1a1a1a 45%, #0d0d0d 100%);
  animation: stripe-pulse 10s ease-in-out infinite alternate;
}

.atmosphere::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.18;
  background-image: radial-gradient(circle, rgba(206, 43, 55, 0.9) 1.15px, transparent 1.4px);
  background-size: 18px 18px;
  mask-image: radial-gradient(circle at 20% 20%, #000 0, transparent 55%);
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.12;
  background-image: radial-gradient(circle, rgba(0, 146, 70, 0.95) 1.15px, transparent 1.4px);
  background-size: 22px 22px;
  background-position: 11px 11px;
  mask-image: radial-gradient(circle at 85% 70%, #000 0, transparent 50%);
}

.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

@keyframes stripe-pulse {
  from {
    filter: saturate(1);
  }
  to {
    filter: saturate(1.12) brightness(1.03);
  }
}

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
}

body.role-atleta .shell {
  grid-template-columns: 1fr;
}

body.role-atleta .sidebar,
.sidebar[hidden] {
  display: none !important;
}

body.role-admin .athlete-only {
  display: none !important;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
  padding: 1.25rem 1rem 1.1rem;
  background: var(--sidebar);
  color: var(--sand);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
}

.sidebar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--green), var(--white), var(--red));
}

.brand {
  padding: 0.2rem 0.35rem 0.4rem;
}

.brand-logo {
  display: block;
  width: min(100%, 210px);
  height: auto;
  margin-bottom: 0.85rem;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.35));
  animation: rise 0.7s ease both;
}

.brand-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--red-hot);
  font-weight: 700;
}

.brand-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 2.2vw, 1.95rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.brand-compact .brand-logo {
  width: min(100%, 160px);
  margin-bottom: 0.55rem;
}

.brand-compact .brand-title {
  font-size: 1.35rem;
}

.side-nav {
  display: grid;
  gap: 1rem;
}

.nav-group {
  display: grid;
  gap: 0.35rem;
}

.nav-group-secondary {
  padding-top: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(244, 244, 241, 0.72);
  font: inherit;
  font-weight: 600;
  text-align: left;
  padding: 0.72rem 0.8rem;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.nav-item:hover {
  color: var(--white);
  background: rgba(255, 255, 255, 0.06);
  transform: translateX(2px);
}

.nav-item.is-active {
  color: var(--white);
  background: linear-gradient(135deg, var(--red), var(--red-hot));
}

.nav-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.side-foot {
  margin-top: auto;
  display: grid;
  gap: 0.65rem;
  padding: 0.85rem 0.55rem 0.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(244, 244, 241, 0.55);
  font-size: 0.78rem;
}

.side-meta {
  margin: 0;
  color: rgba(244, 244, 241, 0.4);
}

.auth-btn {
  width: 100%;
  justify-content: center;
}

.nav-badge {
  margin-left: auto;
  min-width: 1.35rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  text-align: center;
  line-height: 1.3;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 28%),
    #ececea;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(10px);
  animation: rise 0.5s ease both;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.topbar-logo {
  display: block;
  height: 42px;
  width: auto;
}

.topbar-kicker {
  margin: 0 0 0.15rem;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--green-deep);
  font-weight: 700;
}

.topbar-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.4vw, 1.85rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  line-height: 1;
}

/* label { display:grid } must not override HTML hidden */
[hidden],
.report-field[hidden] {
  display: none !important;
}

.topbar-updated {
  margin: 0.35rem 0 0;
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 600;
}

.topbar-updated[hidden] {
  display: none !important;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: 0 0 auto;
}

.btn.icon-btn {
  width: 2.55rem;
  height: 2.55rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #111;
  color: #fff;
}

.btn.icon-btn:hover {
  background: #222;
}

.modal-card-sm {
  width: min(440px, calc(100vw - 1.5rem));
}

.modal-form {
  display: grid;
  gap: 0.75rem;
}

.modal-form .form-actions {
  margin-top: 0.25rem;
}

.report-scope-set {
  margin: 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  display: grid;
  gap: 0.45rem;
}

.report-scope-set legend {
  padding: 0 0.25rem;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fog);
  font-weight: 700;
}

.radio-row {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
  letter-spacing: normal;
  text-transform: none;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}

.radio-row input {
  width: auto;
  min-height: auto;
  margin: 0;
}

.detail-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.detail-tab {
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: #fff;
  border-radius: 999px;
  padding: 0.55rem 0.65rem;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--fog);
}

.detail-tab span {
  font-weight: 500;
  font-size: 0.75rem;
}

.detail-tab.is-active {
  background: #111;
  border-color: #111;
  color: #fff;
}

.detail-panel[hidden] {
  display: none !important;
}

main {
  flex: 1;
  min-height: 0;
  padding: 1rem 1.2rem 1.2rem;
  overflow: hidden;
}

.view {
  height: 100%;
  animation: rise 0.35s ease both;
}

.view[hidden] {
  display: none !important;
}

.dashboard-board {
  gap: 0.85rem;
  overflow: auto;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 0.95rem;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

.dashboard-main {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
  min-height: 0;
}

.dashboard-side {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  min-width: 0;
  min-height: 0;
  padding: 0.95rem;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.05);
}

.dashboard-side-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: -0.01em;
}

.dashboard-side-head p {
  margin: 0.2rem 0 0;
  color: var(--fog);
  font-size: 0.85rem;
}

.dashboard-top-scroll {
  flex: 1;
  min-height: 0;
}

.dashboard-top-scroll .data-table {
  min-width: 0;
}

.dashboard-attended {
  flex: 0 0 auto;
  display: grid;
  gap: 0.45rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.dashboard-attended-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
}

.dashboard-attended-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.4rem 0.55rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.03);
}

.dashboard-attended-list .attended-name {
  font-weight: 650;
  font-size: 0.86rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.dashboard-attended-list .attended-count {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 0.86rem;
}

.dashboard-attended-list .attended-empty {
  color: var(--fog);
  font-size: 0.85rem;
  background: transparent;
  padding-left: 0;
}

.kpi-points {
  display: inline-flex;
  align-items: center;
  margin-top: 0.2rem;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: rgba(206, 43, 55, 0.1);
  color: var(--red);
  font-size: 0.75rem;
  font-weight: 800;
  width: fit-content;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.75rem;
  align-content: start;
}

.kpi-card {
  display: grid;
  gap: 0.35rem;
  grid-column: span 2;
  padding: 1rem 1.05rem;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.05);
  min-height: 7.2rem;
  animation: rise 0.4s ease both;
}

.kpi-card.is-clickable,
#dashboard-top10 tr.is-clickable {
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.kpi-card.is-clickable:hover,
.kpi-card.is-clickable:focus-visible {
  border-color: rgba(0, 0, 0, 0.18);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
  outline: none;
}

#dashboard-top10 tr.is-clickable:hover,
#dashboard-top10 tr.is-clickable:focus-visible {
  background: rgba(0, 0, 0, 0.03);
  outline: none;
}

.kpi-card.is-half {
  grid-column: span 3;
}

.kpi-card.is-full,
.kpi-card.is-wide {
  grid-column: span 6;
}

.kpi-label {
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fog);
  font-weight: 700;
}

.kpi-value {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.4vw, 1.85rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.kpi-hint {
  margin: 0;
  color: var(--fog);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.35;
}

@media (max-width: 1100px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-card,
  .kpi-card.is-half {
    grid-column: span 1;
  }

  .kpi-card.is-full,
  .kpi-card.is-wide {
    grid-column: span 2;
  }
}

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

  .kpi-card,
  .kpi-card.is-half,
  .kpi-card.is-full,
  .kpi-card.is-wide {
    grid-column: span 1;
  }
}

.board {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 0;
  background: var(--panel);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 18px;
  padding: 0.95rem;
  box-shadow: var(--shadow);
}

.toolbar-form {
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  align-items: end;
  flex: 0 0 auto;
}

.settings-form {
  display: grid;
  gap: 1rem;
  max-width: 42rem;
}

.settings-intro {
  margin: 0;
  color: var(--fog);
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.4;
}

.settings-note {
  margin: 1rem 0 0;
  max-width: 42rem;
  color: var(--fog);
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.45;
}

.register-athletes-set {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  gap: 0.55rem;
}

.register-athletes-set legend {
  margin-bottom: 0.2rem;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fog);
  font-weight: 700;
}

.register-athletes-list {
  display: grid;
  gap: 0.45rem;
  max-height: 14rem;
  overflow: auto;
  padding-right: 0.15rem;
}

.settings-grid {
  display: grid;
  gap: 0.85rem;
}

.settings-grid label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fog);
  font-weight: 700;
}

.settings-grid input {
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
}

.board-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex: 0 0 auto;
}

.view-toggle {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.2rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.05);
  flex: 0 0 auto;
  width: fit-content;
}

.toggle-btn {
  border: 0;
  background: transparent;
  color: var(--fog);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
}

.toggle-btn.is-active {
  background: #111;
  color: #fff;
}

.races-pane {
  flex: 1;
  min-height: 0;
}

.races-pane[hidden] {
  display: none !important;
}

.calendar-pane {
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  padding: 0.65rem;
  overflow: hidden;
}

#races-calendar {
  flex: 1;
  min-height: 420px;
}

.fc {
  --fc-border-color: rgba(0, 0, 0, 0.08);
  --fc-button-bg-color: #111;
  --fc-button-border-color: #111;
  --fc-button-hover-bg-color: var(--red);
  --fc-button-hover-border-color: var(--red);
  --fc-button-active-bg-color: var(--red);
  --fc-button-active-border-color: var(--red);
  --fc-event-bg-color: var(--green);
  --fc-event-border-color: var(--green-deep);
  --fc-today-bg-color: rgba(206, 43, 55, 0.08);
  font-family: var(--font-body);
}

.fc .fc-toolbar-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  text-transform: uppercase;
}

.fc .fc-event {
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 4px;
  cursor: pointer;
}

.fc .fc-col-header-cell-cushion,
.fc .fc-daygrid-day-number {
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fog);
  font-weight: 700;
}

input,
select,
button {
  font: inherit;
}

input,
select,
.field-control {
  width: 100%;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.58rem 0.7rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.3;
  min-height: 2.55rem;
  box-sizing: border-box;
}

select,
select.field-control {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  padding-right: 2.2rem;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--fog) 50%),
    linear-gradient(135deg, var(--fog) 50%, transparent 50%);
  background-position:
    calc(100% - 1.05rem) calc(50% - 0.12rem),
    calc(100% - 0.7rem) calc(50% - 0.12rem);
  background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
  background-repeat: no-repeat;
  background-color: #fff;
}

input:focus,
select:focus,
.field-control:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(0, 146, 70, 0.15);
}

.form-actions {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.62rem 1.05rem;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.18s ease, background 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.primary {
  background: var(--red);
  color: #fff;
}

.btn.primary:hover {
  background: var(--red-hot);
}

.btn.ghost {
  background: transparent;
  color: var(--fog);
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.btn.danger {
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(206, 43, 55, 0.35);
  padding: 0.32rem 0.65rem;
  font-size: 0.78rem;
}

.btn.quiet {
  background: rgba(0, 146, 70, 0.1);
  color: var(--green-deep);
  padding: 0.32rem 0.65rem;
  font-size: 0.78rem;
}

.table-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  white-space: nowrap;
}

.data-table th.col-actions,
.data-table td.col-actions {
  text-align: right;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #111;
  color: #fff;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}

.data-table tbody tr {
  transition: background 0.15s ease;
  animation: row-in 0.35s ease both;
}

.standings tbody tr:nth-child(odd) {
  background: #fff;
}

.standings tbody tr:nth-child(even) {
  background: #f3f3f3;
}

.data-table:not(.standings) tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.03);
}

.data-table tbody tr:hover {
  background: rgba(206, 43, 55, 0.06);
}

.standings tbody tr.leader:nth-child(odd),
.standings tbody tr.leader:nth-child(even) {
  background: linear-gradient(90deg, rgba(206, 43, 55, 0.1), #fff 55%);
}

.standings tbody tr.leader:nth-child(even) {
  background: linear-gradient(90deg, rgba(206, 43, 55, 0.1), #f3f3f3 55%);
}

.data-table .pos {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.05rem;
  white-space: nowrap;
}

.pos-num {
  margin-right: 0.35rem;
}

.pos-delta {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}

.pos-delta.is-up {
  color: var(--green-deep);
}

.pos-delta.is-down {
  color: var(--red);
}

.pos-delta.is-same,
.pos-delta.is-new {
  color: var(--fog);
  font-weight: 700;
}

.data-table .pts {
  font-weight: 800;
  color: var(--green-deep);
  font-variant-numeric: tabular-nums;
}

.data-table .athlete-name {
  font-weight: 800;
}

.kind-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
}

.kind-sociale {
  background: rgba(0, 146, 70, 0.12);
  color: var(--green-deep);
}

.kind-jolly {
  background: rgba(206, 43, 55, 0.12);
  color: var(--red);
}

.kind-extra {
  background: rgba(0, 0, 0, 0.08);
  color: var(--ink);
}

.status-in_attesa {
  background: rgba(206, 43, 55, 0.12);
  color: var(--red);
}

.status-confermata {
  background: rgba(0, 146, 70, 0.12);
  color: var(--green-deep);
}

.status-rifiutata {
  background: rgba(0, 0, 0, 0.08);
  color: var(--fog);
}

.report-help {
  margin: 0.35rem 0 0;
  color: var(--fog);
  font-size: 0.9rem;
}

.report-infer {
  margin: 0;
  grid-column: 1 / -1;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  background: rgba(0, 146, 70, 0.08);
  border: 1px solid rgba(0, 146, 70, 0.2);
  color: var(--green-deep);
  font-size: 0.86rem;
  font-weight: 600;
}

.reports-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex: 0 0 auto;
}

.reports-toolbar p {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
}

.toolbar-tools {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.table-search {
  width: min(18rem, 100%);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
}

.table-search:focus {
  outline: 2px solid rgba(0, 146, 70, 0.35);
  outline-offset: 1px;
}

.wizard-steps {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
}

.wizard-step {
  margin: 0;
  padding: 0.45rem 0.5rem;
  border-radius: 999px;
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--fog);
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid transparent;
}

.wizard-step.is-active {
  color: var(--ink);
  background: rgba(0, 146, 70, 0.12);
  border-color: rgba(0, 146, 70, 0.35);
}

.wizard-step.is-done {
  color: var(--green);
  background: rgba(0, 146, 70, 0.08);
}

.wizard-panel {
  display: grid;
  gap: 0.85rem;
}

.wizard-panel[hidden] {
  display: none !important;
}

.wizard-actions {
  justify-content: space-between;
}

.wizard-actions #register-back {
  margin-right: auto;
}

.muted {
  color: var(--fog);
  font-size: 0.8rem;
}

.points-pill {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: rgba(206, 43, 55, 0.1);
  color: var(--red);
  font-size: 0.75rem;
  font-weight: 800;
}

.row-actions {
  display: inline-flex;
  justify-content: flex-end;
  gap: 0.35rem;
}

.presenti-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn.icon-btn-sm {
  width: 1.7rem;
  height: 1.7rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
  color: var(--ink);
  border: 0;
  cursor: pointer;
}

.btn.icon-btn-sm:hover:not(:disabled) {
  background: rgba(0, 146, 70, 0.14);
  color: var(--green-deep);
}

.btn.icon-btn-sm:disabled {
  opacity: 0.35;
  cursor: default;
}

.race-participants-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
  max-height: min(50vh, 22rem);
  overflow: auto;
}

.race-participants-list li {
  padding: 0.45rem 0.65rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.03);
  font-weight: 650;
}

.presence-board {
  gap: 0.9rem;
}

.presence-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) minmax(180px, 1fr) auto;
  gap: 0.75rem;
  align-items: end;
  flex: 0 0 auto;
  padding: 0.85rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.presence-select {
  display: grid;
  gap: 0.3rem;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fog);
  font-weight: 700;
}

.presence-select span {
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fog);
  font-weight: 700;
}

.presence-select select,
#presence-race {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
  color: var(--ink);
}

.presence-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  min-height: 2.5rem;
  color: var(--ink);
  font-size: 0.92rem;
}

.presence-summary strong {
  font-weight: 800;
}

.presence-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: rgba(206, 43, 55, 0.1);
  color: var(--red);
  font-size: 0.75rem;
  font-weight: 800;
}

.presence-count {
  color: var(--fog);
  font-size: 0.82rem;
  font-weight: 600;
}

.presence-empty {
  color: var(--fog);
}

.presence-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  padding: 0.85rem;
  overflow: hidden;
}

.presence-panel-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: -0.01em;
}

.presence-panel-head p {
  margin: 0.2rem 0 0;
  color: var(--fog);
  font-size: 0.85rem;
}

.presence-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.55rem;
  overflow: auto;
  flex: 1;
  min-height: 0;
  align-content: start;
}

.presence-item {
  margin: 0;
}

.presence-check {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  margin: 0;
  padding: 0.75rem 0.8rem;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fafafa;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.presence-check:hover {
  border-color: rgba(0, 146, 70, 0.4);
  background: #fff;
}

.presence-check:has(input:checked) {
  border-color: rgba(0, 146, 70, 0.55);
  background: rgba(0, 146, 70, 0.08);
}

.presence-check input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  flex: 0 0 auto;
  accent-color: var(--green);
}

.presence-check-body {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
}

.presence-name {
  font-weight: 800;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.presence-cat {
  color: var(--fog);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.presence-empty-row {
  grid-column: 1 / -1;
  color: var(--fog);
  padding: 0.5rem 0.2rem;
}

.empty {
  color: var(--fog);
  margin: 0.4rem 0 0;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: -2px;
}

.standings tbody tr.clickable-row:hover .athlete-name {
  color: var(--red);
}

body.modal-open {
  overflow: hidden;
}

.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: min(90vh, 860px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0, 0, 0, 0.08);
  overflow: hidden;
  animation: rise 0.25s ease;
}

.modal-card-athlete {
  width: min(980px, calc(100% - 1.5rem));
  height: min(92vh, 920px);
  max-height: min(92vh, 920px);
}

.modal-card-athlete .modal-head,
.modal-card-athlete .modal-foot {
  flex: 0 0 auto;
}

.modal-card-athlete .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overscroll-behavior: contain;
}

.modal-card-athlete .athlete-chart-block {
  flex: 0 0 auto;
}

.modal-card-athlete .athlete-detail-stack {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.modal-card-athlete .detail-tabs {
  flex: 0 0 auto;
  margin-bottom: 0;
}

.modal-card-athlete .detail-panels {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  position: relative;
}

.modal-card-athlete .detail-panel {
  position: absolute;
  inset: 0;
  height: 100%;
  min-height: 0;
  display: none;
  flex-direction: column;
}

.modal-card-athlete .detail-panel.is-active {
  display: flex;
}

.modal-card-athlete .detail-panel[hidden] {
  display: none !important;
}

.modal-card-athlete .modal-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  max-height: none;
  overflow: auto;
}

.modal-card-athlete .detail-panel.is-empty .modal-table-wrap {
  display: none;
}

.modal-card-athlete .detail-panel-empty {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  background: #fff;
}

.modal-card-athlete .detail-panel.is-empty .detail-panel-empty:not([hidden]) {
  display: flex;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: linear-gradient(180deg, #fafafa, #fff);
}

.modal-kicker {
  margin: 0 0 0.2rem;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--green-deep);
  font-weight: 700;
}

.modal-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  text-transform: uppercase;
  letter-spacing: -0.02em;
}

.modal-sub {
  margin: 0.25rem 0 0;
  color: var(--fog);
  font-size: 0.88rem;
}

.modal-close {
  flex: 0 0 auto;
}

.modal-body {
  padding: 0.85rem 1.1rem;
  min-height: 0;
  overflow: auto;
  flex: 1;
  display: grid;
  gap: 1rem;
}

.athlete-chart-block {
  display: grid;
  gap: 0.45rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 14px;
  background: linear-gradient(180deg, #fbfbfb, #fff);
}

.athlete-chart-block h4 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--ink);
}

.athlete-chart-wrap {
  position: relative;
  height: 150px;
}

.athlete-chart-empty {
  margin: 0;
  color: var(--fog);
  font-size: 0.84rem;
}

.athlete-chart-empty:empty {
  display: none;
}

.detail-block {
  display: grid;
  gap: 0.55rem;
}

.detail-block-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}

.detail-block-head h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--ink);
}

.detail-block-head p {
  margin: 0;
  color: var(--fog);
  font-size: 0.82rem;
  font-weight: 600;
}

.modal-table-wrap {
  max-height: none;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.modal-foot {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
  padding: 0.85rem 1.1rem 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: #fafafa;
}

.modal-stat {
  display: grid;
  gap: 0.15rem;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.modal-stat span {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fog);
  font-weight: 700;
}

.modal-stat strong {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ink);
}

.modal-stat.total {
  border-color: rgba(0, 146, 70, 0.3);
  background: rgba(0, 146, 70, 0.08);
}

.modal-stat.total strong {
  color: var(--green-deep);
}

.toast {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  background: #111;
  color: #fff;
  border-left: 4px solid var(--green);
  border-radius: 12px;
  padding: 0.85rem 1.1rem;
  box-shadow: var(--shadow);
  animation: rise 0.25s ease;
  z-index: 50;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes row-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  body.role-admin .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
  }

  .side-nav {
    grid-template-columns: repeat(2, 1fr);
  }

  .workspace {
    height: auto;
    overflow: visible;
  }

  main {
    overflow: visible;
    padding-bottom: 2rem;
  }

  .view,
  .board {
    height: auto;
  }

  .table-scroll {
    max-height: 70vh;
  }

  .topbar {
    flex-direction: column;
    align-items: start;
  }

  .topbar-note {
    text-align: left;
  }

  .presence-toolbar {
    grid-template-columns: 1fr;
  }

  #races-calendar {
    min-height: 360px;
  }

  .modal-foot {
    grid-template-columns: 1fr;
  }
}
