:root {
  color-scheme: light dark;
  --bg: #eef2f8;
  --bg-deep: #0f1b2d;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --border: #d5deeb;
  --text: #142033;
  --muted: #5c6b82;
  --accent: #0d7a4f;
  --accent-soft: #e6f5ee;
  --accent-2: #1a5fb4;
  --danger: #b42318;
  --warn: #b54708;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(15, 27, 45, 0.08);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #121a2b;
    --surface-2: #0f1626;
    --border: #2a3850;
    --text: #e8eef9;
    --muted: #9aa8c0;
    --accent-soft: #123524;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

/* —— Login board —— */
.login-scene {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(900px 500px at 0% 0%, rgba(26, 95, 180, 0.12), transparent),
    radial-gradient(700px 400px at 100% 100%, rgba(13, 122, 79, 0.14), transparent),
    var(--bg-deep);
  color: #f4f7fb;
}

.login-board {
  width: min(420px, 100%);
}

.login-board-form {
  background: var(--surface);
  color: var(--text);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  gap: 0.85rem;
  align-content: start;
}

.login-board-form h3 {
  margin: 0;
}

/* —— App shell —— */
.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
}

.brand-kicker {
  margin: 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.brand-title {
  margin: 0;
  font-size: 1.05rem;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-chip {
  font-size: 0.82rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

.breadcrumb {
  padding: 0.55rem 1.25rem;
  font-size: 0.88rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: center;
  justify-content: space-between;
}

.scope-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.scope-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.scope-btn.is-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.breadcrumb-crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  min-width: 0;
}

.finder {
  position: relative;
  display: flex;
  gap: 0.4rem;
  margin-left: auto;
  width: min(100%, 420px);
}

.finder select,
.finder input {
  padding: 0.4rem 0.6rem;
}

.finder select {
  flex: 1 1 12rem;
  width: auto;
  max-width: 18rem;
}

.finder input {
  flex: 1;
  min-width: 0;
}

.finder-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 240px;
  overflow: auto;
}

.finder-results button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
}

.finder-results button:hover,
.finder-results button:focus {
  background: var(--surface-2);
}

.finder-results .meta {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.breadcrumb a {
  color: var(--accent-2);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb .sep {
  opacity: 0.5;
}

.view-root {
  flex: 1;
  padding: 0 1.25rem 2.5rem;
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
}

.page-intro h2 {
  margin: 0.5rem 0 0.25rem;
}

/* —— District grid —— */
.district-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.85rem;
  margin-top: 1rem;
}

.district-grid .grid-label {
  grid-column: 1 / -1;
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.district-card {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.12s ease;
  color: inherit;
  font: inherit;
  width: 100%;
}

.district-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-2);
}

.district-card.is-active {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--accent-soft), var(--surface));
}

.district-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  line-height: 1.25;
}

.district-card .meta {
  font-size: 0.78rem;
  color: var(--muted);
}

.district-card .badge {
  display: inline-block;
  margin-top: 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
}

.badge-live {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-soon {
  background: var(--surface-2);
  color: var(--muted);
}

.freshness {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.freshness-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: currentColor;
  flex: none;
}

.freshness-green {
  color: var(--accent);
}

.freshness-orange {
  color: var(--warn);
}

.freshness-red {
  color: var(--danger);
}

.freshness-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.1rem;
  margin: 0.35rem 0 0;
}

.freshness-legend[hidden] {
  display: none;
}

.freshness-legend .freshness {
  margin-top: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
}

.freshness-legend .freshness.is-selected {
  outline: 1px solid currentColor;
  background: var(--surface);
}

/* —— Hub (Épreuves-like) —— */
.hub-hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1rem;
  margin-top: 0.5rem;
  padding: 1.1rem 1.2rem;
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
}

@media (max-width: 800px) {
  .hub-hero {
    grid-template-columns: 1fr;
  }
}

.hub-epreuves-ref {
  margin: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.hub-hero h2 {
  margin: 0.35rem 0 0.15rem;
  font-size: 1.45rem;
}

.hub-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.hub-import {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.hub-col h3 {
  margin: 0 0 0.45rem;
  font-size: 0.85rem;
}

.hub-cells {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.hub-import p {
  margin: 0;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.hub-import strong {
  display: block;
  font-size: 1rem;
}

.hub-import span {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hub-club-search {
  position: relative;
  margin-top: 1rem;
}

.hub-club-search input {
  width: 100%;
}

.hub-club-results {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  top: calc(100% + 0.35rem);
  max-height: 18rem;
  overflow: auto;
  margin: 0;
  padding: 0.35rem 0.5rem 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

.hub-sections {
  display: grid;
  gap: 1rem;
  margin-top: 0.75rem;
}

.hub-club-back {
  margin: 0.25rem 0 0.75rem;
}

.hub-club-back a,
.hub-club-back button {
  border: 0;
  background: none;
  padding: 0;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.district-url.card,
.category-detail > .card,
.category-detail > article.card {
  padding: 0.85rem 1rem;
}

.hub-club-fiche {
  display: grid;
  gap: 0.75rem;
}

.hub-fiche-head.card {
  padding: 0.9rem 1rem;
}

.hub-fiche-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.hub-fiche-head p {
  margin: 0.2rem 0 0.85rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.hub-fiche-cats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

.hub-fiche-cat {
  margin: 0;
  padding: 0.55rem 0.6rem;
  overflow: visible;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
}

.district-url {
  display: grid;
  gap: 0.35rem;
  margin: 0;
}

.district-url input {
  width: 100%;
}

.category-detail {
  display: grid;
  gap: 0.65rem;
}

.category-phase {
  display: grid;
  gap: 0.65rem;
}

.category-phase > h3 {
  margin: 0.35rem 0 0;
  font-size: 1rem;
}

.category-detail article h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.hub-fiche-cats article h4 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.hub-fiche-cats li {
  font-size: 0.78rem;
}

.hub-fiche-cats article h4 span {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hub-fiche-cats ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.2rem;
}

.hub-fiche-cats li span {
  color: var(--muted);
  font-weight: 400;
}

.hub-club-empty {
  margin: 0.35rem 0.9rem 0.9rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.hub-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.hub-section-head {
  padding: 0.75rem 1rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

button.hub-section-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  width: 100%;
  border: 0;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button.hub-section-head h3,
button.hub-section-head p {
  grid-column: 1;
}

.hub-chevron {
  grid-row: 1 / span 2;
  grid-column: 2;
  width: 0.55rem;
  height: 0.55rem;
  margin-left: 0.75rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.hub-section.is-collapsed .hub-chevron {
  transform: rotate(-45deg);
}

.hub-section.is-collapsed .hub-group {
  display: none;
}

.hub-section.is-collapsed .hub-section-head {
  border-bottom: 0;
}

.hub-section-head h3 {
  margin: 0;
  font-size: 1rem;
}

.hub-section-head p {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.hub-group {
  padding: 0.5rem 0.75rem 0.75rem;
}

.hub-group-title {
  margin: 0.5rem 0.35rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.competition-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.competition-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.55rem;
  border-radius: 10px;
  border: 1px solid transparent;
}

.event-list {
  flex: 1 0 100%;
  list-style: none;
  margin: 0.15rem 0 0.1rem 0.85rem;
  padding: 0;
}

.event-list .competition-row {
  padding: 0.35rem 0.4rem;
}

.event-list .competition-open {
  flex: 1;
  display: block;
}

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

.competition-row button {
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  flex: 1;
  padding: 0;
}

.competition-row .label {
  font-weight: 600;
}

.competition-row .sub {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 400;
}

.competition-row .tag {
  font-size: 0.72rem;
  white-space: nowrap;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
}

.tag-live {
  background: var(--accent-soft);
  color: var(--accent);
}

.tag-calendar {
  background: #fff4e5;
  color: var(--warn);
}

@media (prefers-color-scheme: dark) {
  .tag-calendar {
    background: #3a2a12;
  }
}

/* —— Editor —— */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.editor-hero {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.1rem;
  margin-top: 0.5rem;
}

.editor-hero h2 {
  margin: 0;
}

.editor-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.editor-block {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
}

.editor-block h3 {
  margin: 0 0 0.5rem;
}

.status-line {
  min-height: 1.25rem;
  margin: 0.65rem 0 0;
}

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

/* —— Forms & buttons —— */
label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.88rem;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 0.55rem 0.65rem;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  font-weight: 600;
}

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

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-danger {
  background: color-mix(in srgb, var(--danger) 15%, var(--surface));
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

.muted {
  color: var(--muted);
}

.tiny {
  font-size: 0.78rem;
}

.form-error {
  color: var(--danger);
  margin: 0;
  font-size: 0.88rem;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 0.5rem 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 0.5rem;
  text-align: left;
}

.data-table th {
  background: var(--surface-2);
  color: var(--muted);
}

.weekend-results td[rowspan] {
  font-weight: 600;
  vertical-align: top;
  white-space: nowrap;
}

.weekend-results td:last-child {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.weekend-results th:last-child {
  text-align: right;
}

.data-table td input {
  width: 100%;
  min-width: 3.5rem;
}

.verify-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: end;
  margin-bottom: 0.75rem;
}

.verify-row label {
  flex: 1 1 180px;
}

.verify-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
}

.catalog-msg {
  margin-top: 1rem;
  padding: 1.25rem;
}

code {
  font-size: 0.85em;
  background: var(--surface-2);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

a {
  color: var(--accent-2);
}

/* —— Aperçu public (preview.html) —— */
.preview-main {
  width: min(1120px, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 1.25rem 0 3rem;
}

.preview-toolbar {
  display: grid;
  grid-template-columns: 1.2fr 1fr auto;
  gap: 0.75rem;
  align-items: end;
  padding: 1rem 1.1rem;
}

@media (max-width: 800px) {
  .preview-toolbar {
    grid-template-columns: 1fr;
  }
}

.preview-hero {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  margin: 1.25rem 0 0.85rem;
}

.preview-hero h2 {
  margin: 0.15rem 0 0;
  font-size: 1.55rem;
}

.source-pill {
  flex: none;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.source-pill.is-live {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

.source-pill.is-seed {
  color: var(--warn);
}

.preview-grid {
  display: grid;
  grid-template-columns: 1.35fr 0.85fr;
  gap: 1rem;
  align-items: start;
}

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

.match-list {
  display: grid;
  gap: 0.55rem;
}

.match-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.15rem 0.75rem;
  align-items: center;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.match-card.is-ours {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: var(--accent-soft);
}

.match-j {
  grid-column: 1 / -1;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.match-teams {
  display: grid;
  gap: 0.1rem;
}

.match-teams strong {
  font-size: 0.95rem;
}

.match-score {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.05rem;
  min-width: 3.2rem;
  text-align: right;
}

.match-score.is-open {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--muted);
}

.standings-table td.pts {
  font-weight: 700;
}

.standings-table tr.is-ours td {
  background: var(--accent-soft);
}

.json-block {
  margin: 0;
  padding: 0.85rem 1rem;
  overflow: auto;
  max-height: 280px;
  font-size: 0.78rem;
  line-height: 1.45;
  background: var(--bg-deep);
  color: #e8eef9;
  border-radius: 12px;
}

.preview-foot {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
}
