:root {
  color-scheme: dark;

  --bg: #07101d;
  --bg-glow: #173152;
  --surface: #111c2d;
  --surface-soft: #17253a;
  --surface-hover: #1c2c43;
  --border: #2a3c58;
  --border-soft: #344966;
  --text: #f4f7fb;
  --muted: #9cabc1;
  --accent: #63e6be;
  --accent-strong: #35b99e;
  --blue: #5ea7ff;
  --danger: #ff7188;
  --warning: #ffc76b;
  --shadow: 0 16px 42px rgba(0, 0, 0, 0.24);

  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

/* Sans cette règle, tout composant qui fixe son propre « display » (grid,
   flex…) reste affiché malgré l'attribut hidden : le formulaire « Nouvel
   utilisateur » n'a jamais été masqué. */
[hidden] {
  display: none !important;
}

html {
  background: var(--bg);
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 85% -5%, var(--bg-glow) 0, transparent 32rem),
    var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.shell {
  width: min(100% - 28px, 860px);
  margin: 0 auto;
  padding: 20px 0 40px;
}

#app-view:not([hidden]) {
  display: flex;
  flex-direction: column;
}

#app-view > .topbar {
  order: 1;
}

#app-view > #status {
  order: 2;
}

#app-view > .view-nav {
  order: 3;
}

#app-view > [data-view="intro"] {
  order: 4;
}

#app-view > [data-view="status"] {
  order: 5;
}

#app-view > [data-view="preferences"] {
  order: 6;
}

#app-view > [data-view="account"] {
  order: 7;
}

#app-view > [data-view="admin"] {
  order: 9;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 8vw, 2.8rem);
  line-height: 1;
  letter-spacing: -0.055em;
}

h2 {
  font-size: 1.16rem;
  letter-spacing: -0.025em;
}

h3 {
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.eyebrow,
.section-number {
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.section-number {
  margin-bottom: 3px;
}

.muted,
.hint,
.status-date {
  color: var(--muted);
  line-height: 1.52;
}

.hint {
  margin-top: 8px;
  font-size: 0.86rem;
}

.status-date {
  margin-top: 5px;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.brand {
  display: grid;
  gap: 10px;
}

.login-card,
.card {
  border: 1px solid var(--border);
  border-radius: 22px;
  background: linear-gradient(150deg, rgba(23, 37, 58, 0.98), rgba(17, 28, 45, 0.98));
  box-shadow: var(--shadow);
}

.login-card {
  max-width: 470px;
  margin: 12vh auto 0;
  padding: 24px;
}

.card {
  margin-bottom: 14px;
  padding: 18px;
}

.status-card {
  border-color: rgba(99, 230, 190, 0.3);
}

.security-card {
  border-color: rgba(94, 167, 255, 0.3);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar .muted {
  margin-top: 7px;
  font-size: 0.9rem;
}

.view-nav {
  display: flex;
  gap: 6px;
  margin: 22px 0 16px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 5px;
  background: rgba(17, 28, 45, 0.72);
  scrollbar-width: thin;
}

.view-tab {
  position: relative;
  flex: 0 0 auto;
  border: 0;
  border-radius: 11px;
  padding: 11px 12px;
  color: var(--muted);
  background: transparent;
  font-size: 0.86rem;
  font-weight: 750;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.18s ease, background-color 0.18s ease;
}

.view-tab:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.view-tab.is-active {
  color: var(--bg);
  background: var(--accent);
  box-shadow: 0 6px 16px rgba(99, 230, 190, 0.22);
}

.view-tab.is-active:hover {
  color: var(--bg);
  background: var(--accent);
}

.view-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .view-tab {
    transition: none;
  }
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.group-heading {
  display: grid;
  gap: 7px;
  margin: 26px 2px 14px;
}

.group-heading .muted {
  font-size: 0.88rem;
}

label {
  display: grid;
  gap: 7px;
  margin-top: 15px;
  color: var(--muted);
  font-size: 0.89rem;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 13px;
  outline: none;
  padding: 13px;
  color: var(--text);
  background: var(--surface-soft);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input::placeholder,
textarea::placeholder {
  color: #71829a;
}

input:focus,
textarea:focus {
  border-color: var(--blue);
  background: #1a2a41;
  box-shadow: 0 0 0 3px rgba(94, 167, 255, 0.16);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.stack {
  display: grid;
  gap: 6px;
  margin-top: 18px;
}

.primary,
.secondary,
.small,
.icon-button,
.remove {
  border: 0;
  border-radius: 12px;
  font-weight: 750;
  transition: transform 140ms ease, filter 140ms ease, background 140ms ease;
}

.primary:hover,
.secondary:hover,
.small:hover,
.icon-button:hover,
.remove:hover {
  filter: brightness(1.08);
}

.primary:active,
.secondary:active,
.small:active,
.icon-button:active,
.remove:active {
  transform: translateY(1px);
}

.primary {
  width: 100%;
  margin-top: 16px;
  padding: 13px 16px;
  color: #04251e;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.secondary {
  padding: 10px 13px;
  border: 1px solid rgba(94, 167, 255, 0.38);
  color: #b9d8ff;
  background: rgba(94, 167, 255, 0.11);
}

.wide-button {
  width: 100%;
  margin-top: 16px;
}

.small {
  padding: 8px 11px;
  border: 1px solid rgba(94, 167, 255, 0.38);
  color: #b9d8ff;
  background: rgba(94, 167, 255, 0.11);
}

.icon-button {
  flex: 0 0 auto;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface-soft);
}

.repeaters {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.repeat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.repeat-row:has([data-field]) {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
}

.remove {
  padding: 7px 12px;
  color: var(--danger);
  background: rgba(255, 113, 136, 0.11);
  font-size: 1.28rem;
  line-height: 1;
}

.two-columns {
  display: grid;
  gap: 14px;
}

.time-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px 10px;
}

/* La date est plus longue à lire qu'une heure : elle garde sa propre ligne. */
.time-fields > label:first-child {
  grid-column: 1 / -1;
}

.time-fields input {
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 1.15rem;
  font-weight: 700;
  /* Cible tactile confortable au pouce. */
  min-height: 52px;
}

/* Safari iOS centre mal les champs date et les tronque sous 360 px. */
.time-fields input[type="date"],
input[type="date"] {
  min-height: 52px;
  text-align: left;
  appearance: none;
}

.toggle {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  margin-top: 18px;
  cursor: pointer;
}

.toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.toggle-control {
  position: relative;
  width: 42px;
  height: 24px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: #0d1726;
  transition: background 180ms ease, border-color 180ms ease;
}

.toggle-control::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  content: "";
  transition: transform 180ms ease, background 180ms ease;
}

.toggle input:checked + .toggle-control {
  border-color: rgba(99, 230, 190, 0.7);
  background: rgba(99, 230, 190, 0.21);
}

.toggle input:checked + .toggle-control::after {
  transform: translateX(18px);
  background: var(--accent);
}

.toggle input:focus-visible + .toggle-control {
  outline: 3px solid rgba(94, 167, 255, 0.34);
  outline-offset: 3px;
}

.toggle strong,
.toggle small {
  display: block;
}

.schedule-card {
  border-color: rgba(99, 230, 190, 0.38);
  background:
    linear-gradient(145deg, rgba(25, 55, 64, 0.98), rgba(17, 28, 45, 0.98));
}

.schedule-summary {
  margin-top: 7px;
  color: var(--accent);
  font-size: 0.84rem;
  line-height: 1.45;
}

.toggle strong {
  color: var(--text);
  font-size: 0.9rem;
}

.toggle small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.status {
  min-height: 0;
  margin: 0;
}

.status.success,
.status.error {
  margin-top: 14px;
  border-radius: 13px;
  padding: 12px;
}

.status.success {
  color: var(--accent);
  background: rgba(99, 230, 190, 0.1);
}

.status.error,
.error {
  color: var(--danger);
}

.status.error {
  background: rgba(255, 113, 136, 0.1);
}

.error {
  min-height: 1.2em;
  margin-top: 6px;
  font-size: 0.88rem;
}

.status-summary {
  margin-top: 16px;
}

.status-summary .status {
  color: var(--accent);
  font-weight: 750;
}

details {
  margin-top: 14px;
}

summary {
  cursor: pointer;
  color: #b9d8ff;
  font-size: 0.9rem;
}

pre {
  max-height: 420px;
  margin: 12px 0 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  color: #c8dcf5;
  background: #07101d;
  font-size: 0.78rem;
  line-height: 1.48;
  white-space: pre-wrap;
}

.intro-copy {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.intro-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.intro-subtitle {
  margin-top: 10px;
  color: var(--text);
  font-size: 1rem;
  font-weight: 750;
}

/* Étapes numérotées : le compteur remplace la puce native, qui se
   désaligne dès que le texte d'une étape passe sur plusieurs lignes. */
.intro-steps {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  counter-reset: intro-step;
  list-style: none;
}

.intro-steps > li {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 4px 12px;
  align-items: start;
  counter-increment: intro-step;
}

.intro-steps > li::before {
  content: counter(intro-step);
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  grid-row: 1 / span 2;
  border-radius: 50%;
  background: var(--surface-hover);
  box-shadow: inset 0 0 0 1px var(--border-soft);
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.intro-steps > li > strong {
  color: var(--text);
  font-size: 0.97rem;
  line-height: 1.4;
}

.intro-steps > li > span {
  color: var(--muted);
  line-height: 1.6;
}

.intro-steps em,
.intro-list em {
  color: var(--text);
  font-style: normal;
  font-weight: 700;
}

@media (min-width: 680px) {
  .shell {
    padding-top: 38px;
  }

  .card {
    padding: 24px;
  }

  .two-columns {
    grid-template-columns: 1fr 1fr;
  }

  .time-fields {
    max-width: 540px;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr);
  }

  /* Au-delà de 680 px les trois champs tiennent sur une ligne : la date
     n'a plus besoin de la sienne. */
  .time-fields > label:first-child {
    grid-column: auto;
  }

  /* Menu : sur grand écran on abandonne la barre défilante du téléphone
     pour des onglets répartis sur toute la largeur. */
  .view-nav {
    gap: 4px;
    padding: 6px;
    overflow-x: visible;
  }

  .view-tab {
    flex: 1 1 0;
    padding: 13px 14px;
    font-size: 0.92rem;
    text-align: center;
  }

}

.users-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px;
  background: rgba(7, 16, 29, 0.42);
}

.user-row strong,
.user-row small {
  display: block;
}

.user-row strong {
  color: var(--text);
}

.user-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.user-row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.user-form {
  display: grid;
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.user-form-actions {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 10px;
  margin-top: 16px;
}

.user-form-actions .primary {
  margin-top: 0;
}

.compact-primary {
  padding: 11px 14px;
}

select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 13px;
  outline: none;
  padding: 13px;
  color: var(--text);
  background: var(--surface-soft);
}

select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(94, 167, 255, 0.16);
}

/* ---------------------------------------------------------------------------
   Statut : réservation
   --------------------------------------------------------------------------- */

.status.warning {
  margin-top: 14px;
  border-radius: 13px;
  padding: 12px;
  color: var(--warning);
  background: rgba(255, 199, 107, 0.1);
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-on {
  color: var(--accent);
  background: rgba(99, 230, 190, 0.12);
  box-shadow: inset 0 0 0 1px rgba(99, 230, 190, 0.32);
}

.badge-off {
  color: var(--muted);
  background: rgba(156, 171, 193, 0.1);
  box-shadow: inset 0 0 0 1px var(--border-soft);
}

.reservation-latest {
  margin-top: 16px;
}

.reservation-hero {
  display: grid;
  gap: 6px;
  justify-items: start;
  margin-bottom: 14px;
}

.reservation-when {
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.3;
}

/* Majuscule à la première lettre seulement : « capitalize » écrivait
   « Octobre » et « 21 H ». */
.reservation-when::first-letter {
  text-transform: uppercase;
}

.reservation-place {
  color: var(--accent);
  font-weight: 750;
}

/* Liste « libellé / valeur » partagée par la réservation et les
   planifications : empilée sur téléphone, en deux colonnes ensuite. */
.detail-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.detail-list > div {
  display: grid;
  gap: 2px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.detail-list dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.detail-list dd {
  margin: 0;
  color: var(--text);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------------------
   Administration : planifications
   --------------------------------------------------------------------------- */

.plannings-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.planning-item {
  display: grid;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: rgba(7, 16, 29, 0.42);
}

.planning-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.planning-head strong {
  font-size: 1.02rem;
}

.planning-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.small.danger {
  border-color: rgba(255, 113, 136, 0.42);
  color: #ffc2cc;
  background: rgba(255, 113, 136, 0.1);
}

.chip-fieldset {
  min-width: 0;
  margin: 14px 0 0;
  border: 0;
  padding: 0;
}

.chip-fieldset legend {
  margin-bottom: 8px;
  padding: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* label et input ont des styles globaux (marge, largeur 100 %, rembourrage)
   pensés pour les champs de texte : on les neutralise pour les cases. */
.chip,
.check-row {
  margin-top: 0;
}

.chip {
  position: relative;
  cursor: pointer;
}

.chip input {
  position: absolute;
  opacity: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  cursor: pointer;
}

.chip span {
  display: block;
  min-width: 56px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 9px 12px;
  color: var(--muted);
  background: var(--surface-soft);
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.chip input:checked + span {
  border-color: rgba(99, 230, 190, 0.5);
  color: var(--bg);
  background: var(--accent);
}

.chip input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.check-list {
  display: grid;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 6px;
  background: rgba(7, 16, 29, 0.42);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border-radius: 10px;
  padding: 0 10px;
  color: var(--text);
  cursor: pointer;
}

.check-row:hover {
  background: var(--surface-hover);
}

.check-row input {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin: 0;
  padding: 0;
  border-radius: 4px;
  accent-color: var(--accent);
}

@media (min-width: 680px) {
  .detail-list > div {
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 14px;
    align-items: baseline;
  }

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

  .plannings-list {
    grid-template-columns: 1fr;
  }
}

/* ---------------------------------------------------------------------------
   Statut : Ma réservation, lue sur Paris Tennis
   --------------------------------------------------------------------------- */

.sync-line {
  min-height: 1.3em;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.sync-line.busy {
  color: var(--blue);
}

.sync-line.busy::before {
  content: "";
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-right: 0.55em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -0.1em;
  animation: sync-spin 0.8s linear infinite;
}

.sync-line.warning {
  color: var(--warning);
}

@keyframes sync-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .sync-line.busy::before {
    animation-duration: 2.4s;
  }
}

.credit-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.credit-chip {
  display: grid;
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  background: rgba(7, 16, 29, 0.42);
}

.credit-chip small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.credit-chip strong {
  color: var(--text);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.credit-chip strong span {
  color: var(--muted);
  font-weight: 600;
}

.reservation-list {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.reservation-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: rgba(7, 16, 29, 0.42);
}

.reservation-item .reservation-hero {
  margin-bottom: 12px;
}

.link-button {
  display: inline;
  border: 0;
  padding: 0;
  color: var(--blue);
  background: none;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

.nowrap {
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   Préférences : enregistrement, puis choix du mode de réservation
   --------------------------------------------------------------------------- */

.save-card .primary {
  margin-top: 0;
}

.save-card .status.success,
.save-card .status.error,
.save-card .status.warning {
  margin-top: 12px;
}

.launch-section {
  display: grid;
  gap: 14px;
  margin-top: 6px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 5px;
  background: rgba(17, 28, 45, 0.72);
}

.segment {
  border: 0;
  border-radius: 11px;
  padding: 13px 8px;
  color: var(--muted);
  background: transparent;
  font-size: 0.9rem;
  font-weight: 750;
  line-height: 1.25;
  transition: color 0.18s ease, background-color 0.18s ease;
}

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

.segment.is-active,
.segment.is-active:hover {
  color: var(--bg);
  background: var(--accent);
  box-shadow: 0 6px 16px rgba(99, 230, 190, 0.22);
}

.segment:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.run-card .primary,
.schedule-card .primary {
  margin-top: 16px;
}

.run-card label {
  margin-top: 18px;
}

.badge-group {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
