/* Socle de l'interface : réinitialisation, mise en page, et tous les composants
   partagés (en-tête, boutons, champs, tableaux, badges, modale, notifications).
   Les pages n'ajoutent que ce qui leur est propre. */

/* ---------------------------------------------------------------- Base --- */

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

/* Les composants imposent display:flex/grid, plus spécifique que le display:none
   du navigateur : sans cette règle, l'attribut hidden ne masque plus rien. */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  /* Deux halos aux couleurs du club : l'écran de gestion reste sobre mais
     porte l'identité visuelle jusque dans le fond. */
  background-image:
    radial-gradient(900px 500px at 10% -10%, rgb(var(--brand-primary-rgb) / 0.16), transparent 70%),
    radial-gradient(700px 420px at 95% 0%, rgb(var(--brand-secondary-rgb) / 0.12), transparent 65%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.1;
  margin: 0;
}

h1 {
  font-size: var(--text-2xl);
  text-transform: uppercase;
}

h2 {
  font-size: var(--text-lg);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

h3 {
  font-size: var(--text-md);
}

p {
  margin: 0;
}

a {
  color: var(--brand-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection {
  background: rgb(var(--brand-primary-rgb) / 0.35);
}

svg {
  flex: none;
}

.icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

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

/* ------------------------------------------------------ Menu latéral --- */

body.has-sidebar {
  padding-left: var(--sidebar-w-collapsed);
}

.app-sidebar {
  --nav-pad: 10px;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar-w-collapsed);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: 18px var(--nav-pad) 16px;
  background:
    radial-gradient(140px 110px at 12% -8%, rgb(var(--brand-secondary-rgb) / 0.34), transparent 72%),
    radial-gradient(180px 140px at 110% 6%, rgb(var(--brand-primary-rgb) / 0.28), transparent 68%),
    color-mix(in srgb, var(--bg-elevated) 86%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-right: 1px solid rgb(var(--brand-primary-rgb) / 0.18);
  border-radius: 0 28px 28px 0;
  box-shadow: var(--shadow-md), 8px 0 32px -20px rgb(var(--brand-primary-rgb) / 0.45);
  overflow-x: hidden;
  overflow-y: auto;
  transition:
    width var(--transition-slow),
    padding var(--transition-slow),
    box-shadow var(--transition-slow);
}

.app-sidebar[data-expanded] {
  width: var(--sidebar-w);
  --nav-pad: 14px;
  box-shadow: var(--shadow-lg), 16px 0 40px -18px rgb(var(--brand-primary-rgb) / 0.5);
}

.app-sidebar::after {
  content: "";
  position: absolute;
  inset: 18px 0 18px auto;
  width: 3px;
  border-radius: var(--radius-pill);
  background: var(--brand-gradient);
  opacity: 0.95;
}

.club-identity {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  flex: 0 0 auto;
  color: inherit;
  text-decoration: none;
  border-radius: 18px;
  padding: 4px;
  transition: background-color var(--transition), transform var(--transition);
}

.app-sidebar[data-expanded] .club-identity {
  justify-content: flex-start;
}

.club-identity:hover {
  text-decoration: none;
  background: rgb(var(--brand-primary-rgb) / 0.1);
}

.club-identity:active {
  transform: scale(0.98);
}

/* Le logo est toujours présent : image du club si elle existe, monogramme
   sur dégradé sinon — jamais d'espace vide dans l'en-tête. */
.club-logo {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  flex: none;
  overflow: hidden;
  background: var(--brand-gradient);
  color: var(--brand-on-gradient);
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-brand);
}

.club-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.club-logo-lg {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-lg);
  font-size: var(--text-xl);
}

.club-text {
  min-width: 0;
  display: none;
  flex-direction: column;
}

.app-sidebar[data-expanded] .club-text {
  display: flex;
}

.club-name {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.club-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.main-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  min-height: 48px;
  padding: 6px;
  border-radius: 16px;
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition:
    color var(--transition),
    background-color var(--transition),
    transform var(--transition),
    box-shadow var(--transition);
}

.app-sidebar[data-expanded] .nav-link {
  justify-content: flex-start;
  padding: 6px 10px 6px 6px;
}

/* Même token marque pour toutes les icônes : changer les couleurs du club
   retinte fond et glyphe de la même façon, sans cycle primaire / secondaire / info. */
.nav-ico {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: none;
  background: rgb(var(--brand-primary-rgb) / 0.16);
  color: var(--brand-primary);
  transition: background-color var(--transition), color var(--transition), transform var(--transition);
}

.nav-label {
  display: none;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.app-sidebar[data-expanded] .nav-label {
  display: inline;
}

.nav-link:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--brand-primary) 12%, var(--surface-hover));
  text-decoration: none;
  transform: translateX(3px);
}

.nav-link:hover .nav-ico {
  transform: scale(1.06);
}

.nav-link:active {
  transform: scale(0.98);
}

.nav-link.active {
  color: var(--brand-on-cta);
  background: var(--brand-cta);
  box-shadow: var(--shadow-brand);
}

.nav-link.active .nav-ico {
  background: rgb(255 255 255 / 0.28);
  color: inherit;
}

.nav-link.active:hover {
  color: var(--brand-on-cta);
}

.nav-link .icon {
  width: 18px;
  height: 18px;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--space-2);
  flex: none;
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid rgb(var(--brand-primary-rgb) / 0.16);
}

.app-sidebar[data-expanded] .sidebar-footer {
  flex-direction: row;
  justify-content: flex-start;
}

.app-sidebar[data-expanded] .user-menu {
  flex: 1;
  min-width: 0;
}

.user-chip-name,
.user-chip > .icon {
  display: none;
}

.app-sidebar[data-expanded] .user-chip-name {
  display: inline;
}

.app-sidebar[data-expanded] .user-chip > .icon {
  display: block;
}

.app-sidebar:not([data-expanded]) .user-chip {
  justify-content: center;
  width: 48px;
  padding: 0;
  border-radius: 16px;
}

@media (hover: hover) and (pointer: fine) {
  .app-sidebar:hover {
    width: var(--sidebar-w);
    --nav-pad: 14px;
    box-shadow: var(--shadow-lg), 16px 0 40px -18px rgb(var(--brand-primary-rgb) / 0.5);
  }

  .app-sidebar:hover .club-identity,
  .app-sidebar:hover .nav-link {
    justify-content: flex-start;
  }

  .app-sidebar:hover .nav-link {
    padding: 6px 10px 6px 6px;
  }

  .app-sidebar:hover .club-text {
    display: flex;
  }

  .app-sidebar:hover .nav-label {
    display: inline;
  }

  .app-sidebar:hover .sidebar-footer {
    flex-direction: row;
    justify-content: flex-start;
  }

  .app-sidebar:hover .user-menu {
    flex: 1;
    min-width: 0;
  }

  .app-sidebar:hover .user-chip-name {
    display: inline;
  }

  .app-sidebar:hover .user-chip > .icon {
    display: block;
  }

  .app-sidebar:hover .user-chip {
    justify-content: flex-start;
    width: auto;
    padding: var(--space-1) var(--space-2) var(--space-1) var(--space-1);
    border-radius: var(--radius-pill);
  }
}

[data-theme="light"] .app-sidebar {
  background:
    radial-gradient(140px 110px at 12% -8%, rgb(var(--brand-secondary-rgb) / 0.22), transparent 72%),
    radial-gradient(180px 140px at 110% 6%, rgb(var(--brand-primary-rgb) / 0.16), transparent 68%),
    color-mix(in srgb, var(--bg-elevated) 94%, transparent);
  border-right-color: rgb(var(--brand-primary-rgb) / 0.14);
}

@media (prefers-reduced-motion: reduce) {
  .club-identity:active,
  .nav-link:hover,
  .nav-link:active,
  .nav-link:hover .nav-ico,
  .icon-btn:active {
    transform: none;
  }
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: 14px;
  border: 1px solid rgb(var(--brand-primary-rgb) / 0.18);
  background: rgb(var(--brand-primary-rgb) / 0.1);
  color: var(--brand-primary);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background-color var(--transition), transform var(--transition);
}

.icon-btn:hover {
  color: var(--text);
  border-color: rgb(var(--brand-secondary-rgb) / 0.45);
  background: rgb(var(--brand-secondary-rgb) / 0.18);
}

.icon-btn:active {
  transform: scale(0.96);
}

/* Menu du compte connecté */
.user-menu {
  position: relative;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2) var(--space-1) var(--space-1);
  height: 40px;
  flex: 1;
  min-width: 0;
  border-radius: var(--radius-pill);
  border: 1px solid rgb(var(--brand-primary-rgb) / 0.2);
  background: rgb(var(--brand-primary-rgb) / 0.08);
  color: var(--text);
  font-family: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: border-color var(--transition), background-color var(--transition), transform var(--transition);
}

.user-chip:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand-gradient);
  color: var(--brand-on-gradient);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  flex: none;
}

.user-chip-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  padding: var(--space-2);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 50;
}

.menu[hidden] {
  display: none;
}

.menu-head {
  padding: var(--space-2) var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-2);
}

.menu-head strong {
  display: block;
  font-size: var(--text-sm);
}

.menu-head span {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
  transition: background-color var(--transition), color var(--transition);
}

.menu-item:hover {
  background: var(--surface-hover);
  text-decoration: none;
}

.menu-item.danger {
  color: var(--danger);
}

/* -------------------------------------------------------- Mise en page --- */

.page {
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--space-8) var(--gutter) var(--space-12);
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.page-head-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.eyebrow {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand-primary);
}

.page-sub {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.page-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-left: auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: var(--space-4);
}

.widget {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.widget:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.widget h3 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.widget h3 .icon {
  width: 16px;
  height: 16px;
  color: var(--brand-primary);
}

.widget-stat {
  gap: var(--space-2);
}

.big-stat {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.big-stat.accent {
  color: var(--brand-primary);
}

.big-stat.success {
  color: var(--success);
}

.big-stat.danger {
  color: var(--danger);
}

.widget-wide {
  grid-column: span 2;
}

.widget-list {
  display: flex;
  flex-direction: column;
}

.widget-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border);
}

.widget-row:first-child {
  padding-top: 0;
}

.widget-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.widget-row > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.widget-row > span:last-child {
  flex: none;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.widget-empty {
  color: var(--text-subtle);
  font-size: var(--text-sm);
}

.widget-child h3 {
  font-family: var(--font-display);
  font-size: var(--text-md);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text);
}

.widget-child .child-team {
  font-size: var(--text-xs);
  color: var(--brand-primary);
  letter-spacing: 0.08em;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
}

.form-grid > .form-full,
.form-grid > .modal-actions,
.form-grid > button[type="submit"],
.form-grid > .btn-primary {
  grid-column: 1 / -1;
}

.section {
  margin-bottom: var(--space-8);
}

.hint {
  margin: 0 0 var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.empty-state {
  padding: var(--space-8);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* ---------------------------------------------------------- Boutons --- */

.btn-primary,
.btn-secondary,
.btn-danger,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0 var(--space-4);
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition),
    background-color var(--transition), border-color var(--transition), color var(--transition);
}

/* --brand-cta vaut le dégradé du club, ou son aplat primaire quand aucune
   encre ne reste lisible d'un bout à l'autre du dégradé (voir utils/branding.js). */
.btn-primary {
  background: var(--brand-cta);
  color: var(--brand-on-cta);
  box-shadow: var(--shadow-brand);
}

.btn-primary:hover {
  filter: saturate(1.1) brightness(1.06);
}

.btn-secondary {
  background: var(--surface-inset);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn-danger {
  background: transparent;
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-soft);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface-inset);
}

.btn-primary:active,
.btn-secondary:active,
.btn-danger:active,
.btn-ghost:active {
  transform: translateY(1px);
}

.btn-primary[disabled],
.btn-secondary[disabled],
.btn-danger[disabled],
.btn-ghost[disabled],
button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-sm {
  min-height: 32px;
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
}

.btn-block {
  width: 100%;
}

.file-trigger {
  cursor: pointer;
}

.file-trigger input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

/* ---------------------------------------------------------- Formulaires --- */

label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-inset);
  color: var(--text);
  font-family: inherit;
  font-size: var(--text-base);
  transition: border-color var(--transition), box-shadow var(--transition);
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  flex: none;
  margin: 0;
  accent-color: var(--brand-primary);
}

label:has(> input[type="checkbox"]),
label:has(> input[type="radio"]) {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
}

input[type="color"] {
  padding: var(--space-1);
  height: 44px;
  cursor: pointer;
}

input[type="file"] {
  padding: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgb(var(--brand-primary-rgb) / 0.22);
}

input::placeholder {
  color: var(--text-subtle);
}

select {
  appearance: none;
  padding-right: var(--space-8);
  /* Chevron dessiné en CSS : pas d'image externe à charger. */
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  color: var(--text);
  cursor: pointer;
}

/* Les <option> héritent du fond du système sur certaines plateformes. */
option {
  background: var(--bg-elevated);
  color: var(--text);
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-4) var(--space-5);
  margin: 0;
}

.check-group {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-2) var(--space-4);
}

legend {
  padding: 0 var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand-primary);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.error {
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: var(--text-sm);
  text-align: center;
}

/* --------------------------------------------------------------- Filtres --- */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.filters input,
.filters select {
  width: auto;
  min-width: 0;
  flex: 0 1 auto;
}

.filters input[type="search"] {
  flex: 1 1 260px;
}

/* ------------------------------------------------------------- Bandeaux --- */

.alerts-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent);
  border-left-width: 3px;
  border-radius: var(--radius);
  background: var(--warning-soft);
  color: var(--text);
  font-size: var(--text-sm);
}

.alerts-banner .icon {
  color: var(--warning);
}

/* L'action éventuelle du bandeau reste collée à droite, alignée sur le texte. */
.alerts-banner button {
  margin-left: auto;
  flex: none;
}

/* ------------------------------------------------------------ Tableaux --- */

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

th,
td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody tr {
  transition: background-color var(--transition);
}

tbody tr:hover {
  background: var(--surface-inset);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody td:first-child {
  font-weight: 600;
  color: var(--text);
}

/* Colonne d'actions : boutons alignés à droite, jamais coupés ni décalés. */
tbody td:last-child:has(button),
tbody td:last-child:has(a.btn-secondary) {
  text-align: right;
  white-space: nowrap;
}

tbody td:last-child button + button,
tbody td:last-child a + button,
tbody td:last-child button + a {
  margin-left: var(--space-2);
}

td button {
  min-height: 32px;
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
}

.loading-row {
  text-align: center;
  color: var(--text-muted);
  padding: var(--space-8) var(--space-4);
}

/* -------------------------------------------------------------- Badges --- */

.badge,
.status-pill,
.event-type-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge-VALIDE,
.status-pill.VALIDE,
.status-pill.PAID,
.status-pill.ACTIVE {
  background: var(--success-soft);
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 28%, transparent);
}

.badge-BIENTOT_EXPIRE,
.status-pill.BIENTOT_EXPIRE,
.status-pill.PENDING,
.status-pill.PAUSED {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: color-mix(in srgb, var(--warning) 28%, transparent);
}

.badge-EXPIRE,
.badge-MANQUANT,
.status-pill.EXPIRE,
.status-pill.MANQUANT,
.status-pill.LATE,
.status-pill.UNPAID,
.status-pill.CANCELLED,
.status-pill.EXPIRED {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 28%, transparent);
}

/* --------------------------------------------------------- Pagination --- */

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-5);
}

.pagination button {
  min-width: 40px;
  min-height: 40px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-inset);
  color: var(--text-muted);
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background-color var(--transition);
}

.pagination button:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.pagination button.active {
  background: var(--brand-primary);
  border-color: transparent;
  color: var(--brand-on-primary);
  font-weight: 600;
}

/* -------------------------------------------------------------- Modale --- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: var(--scrim);
  backdrop-filter: blur(3px);
  animation: fade-in var(--transition) both;
}

.modal-box {
  width: 100%;
  max-width: min(720px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  animation: rise var(--transition-slow) both;
}

.modal-box.modal-lg {
  max-width: min(960px, 100%);
}

.modal-box.modal-xl {
  max-width: min(1120px, 100%);
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.modal-header h2 {
  font-size: var(--text-md);
}

.modal-close {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: color var(--transition), background-color var(--transition);
}

.modal-close:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.modal-body {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Les formulaires des modales empilent des <label> contenant leur champ. */
.modal-body form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.modal-body form.form-grid {
  display: grid;
}

.modal-body label {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.modal-body label:has(> input[type="checkbox"]),
.modal-body label:has(> input[type="radio"]) {
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
  text-transform: none;
  letter-spacing: normal;
  font-size: var(--text-sm);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

/* ---------------------------------------------------------- Documents --- */

.doc-section {
  margin-top: var(--space-2);
}

.doc-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3) 0;
}

.doc-row label {
  margin: 0;
}

.doc-row + .doc-row {
  border-top: 1px solid var(--border);
}

.doc-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
  text-transform: none;
}

.doc-link {
  font-size: var(--text-sm);
  font-weight: 600;
}

.doc-empty {
  font-size: var(--text-sm);
  color: var(--text-subtle);
}

.doc-input {
  grid-column: 1 / -1;
}

/* ------------------------------------------------------- Notifications --- */

.toast-container {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: min(360px, calc(100vw - 2 * var(--space-5)));
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  border-left: 3px solid var(--text-muted);
  animation: slide-in var(--transition-slow) both;
  transition: opacity var(--transition-slow), transform var(--transition-slow);
}

.toast-success {
  border-left-color: var(--success);
}

.toast-success .icon {
  color: var(--success);
}

.toast-error {
  border-left-color: var(--danger);
}

.toast-error .icon {
  color: var(--danger);
}

.toast-warning {
  border-left-color: var(--warning);
}

.toast-warning .icon {
  color: var(--warning);
}

.toast-fade-out {
  opacity: 0;
  transform: translateX(12px);
}

/* ------------------------------------------------------------ Animations --- */

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

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

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

/* ------------------------------------------------------------- Onglets --- */

.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.tab-bar button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font: inherit;
  cursor: pointer;
}

.tab-bar button.active {
  background: var(--brand-primary);
  color: var(--brand-on-primary, #fff);
  border-color: transparent;
}

.rsvp-pill {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--surface-2, var(--surface));
}

.rsvp-pill.PRESENT { color: var(--success); }
.rsvp-pill.ABSENT { color: var(--danger); }
.rsvp-pill.UNCERTAIN { color: var(--warning); }

/* ------------------------------------------------------------ Responsive --- */

@media (max-width: 900px) {
  .app-sidebar {
    border-radius: 0 22px 22px 0;
  }
}

@media (max-width: 720px) {
  .widget-wide {
    grid-column: span 1;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: var(--text-xl);
  }

  .page {
    padding-top: var(--space-5);
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .btn-primary {
    flex: 1;
  }

  .filters input[type="search"] {
    flex-basis: 100%;
  }

  .filters select {
    flex: 1 1 140px;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .toast-container {
    left: var(--space-4);
    right: var(--space-4);
    bottom: calc(var(--space-4) + 76px + env(safe-area-inset-bottom));
    max-width: none;
  }
}

/* ------------------------------------------- Lancement : mobile et impayés --- */

.is-unpaid {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.unpaid-mark {
  display: inline-flex;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

.player-name {
  font-weight: 600;
}

.player-photo-preview {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 16px;
}

.reminder-banner {
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  border-radius: 16px;
  background: color-mix(in srgb, var(--warning) 18%, var(--bg-elevated));
  border: 1px solid color-mix(in srgb, var(--warning) 45%, transparent);
}

.reminder-banner p + p {
  margin-top: 8px;
}

.appel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 12px;
}

.appel-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  border: 2px solid transparent;
  border-radius: 18px;
  background: var(--bg-elevated);
  color: inherit;
  cursor: pointer;
  min-height: 148px;
}

.appel-card.is-present {
  border-color: var(--success);
  background: color-mix(in srgb, var(--success) 16%, var(--bg-elevated));
}

.appel-card.is-absent {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 14%, var(--bg-elevated));
}

.appel-photo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  background: rgb(var(--brand-primary-rgb) / 0.2);
  display: grid;
  place-items: center;
  font-weight: 700;
  overflow: hidden;
}

.appel-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.appel-name {
  font-size: 0.85rem;
  text-align: center;
  line-height: 1.2;
}

@media (max-width: 768px) {
  body.has-sidebar {
    padding-left: 0;
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }

  .app-sidebar,
  .app-sidebar[data-expanded],
  .app-sidebar:hover {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: stretch;
    gap: 4px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-radius: 18px 18px 0 0;
    border-right: 0;
    border-top: 1px solid rgb(var(--brand-primary-rgb) / 0.18);
    overflow: hidden;
  }

  .app-sidebar .club-identity,
  .app-sidebar .club-text,
  .app-sidebar .sidebar-footer .user-chip-name,
  .app-sidebar .user-chip > .icon,
  .app-sidebar .nav-label {
    display: none;
  }

  .app-sidebar .sidebar-footer {
    flex-direction: row;
    margin: 0;
    gap: 4px;
  }

  .app-sidebar .main-nav {
    display: flex;
    flex: 1;
    flex-direction: row;
    overflow-x: auto;
    gap: 2px;
  }

  .app-sidebar .nav-link {
    flex-direction: column;
    justify-content: center;
    min-width: 64px;
    min-height: 52px;
    padding: 6px;
  }

  .app-sidebar .nav-label,
  .app-sidebar[data-expanded] .nav-label,
  .app-sidebar:hover .nav-label {
    display: block;
    font-size: 0.65rem;
    opacity: 1;
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
