:root {
  --fond: #f4f5f7;
  --surface: #ffffff;
  --texte: #1d2330;
  --texte-doux: #5e6778;
  --bordure: #dfe2e8;
  --accent: #c2410c;
  --accent-fonce: #9a3412;
  --menu: #1d2330;
  --menu-texte: #c9ceda;
  --ok: #15803d;
  --ok-fond: #e8f6ec;
  --erreur: #b91c1c;
  --erreur-fond: #fdecec;
  --info-fond: #fff4e8;
  --rayon: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--texte);
  background: var(--fond);
}

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

/* --- Structure --- */
.app { display: flex; min-height: 100vh; }

.menu {
  width: 220px;
  flex-shrink: 0;
  background: var(--menu);
  color: var(--menu-texte);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}
.menu .logo {
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  text-decoration: none;
  padding: 0 20px 20px;
}
.menu ul { list-style: none; margin: 0; padding: 0; flex: 1; }
.menu li a, .menu li span {
  display: block;
  padding: 9px 20px;
  color: var(--menu-texte);
  text-decoration: none;
}
.menu li a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.menu a.actif { background: rgba(255, 255, 255, .1); color: #fff; box-shadow: inset 3px 0 var(--accent); }
.menu .bientot { opacity: .4; cursor: default; }
.menu-pied { padding: 12px 20px 0; border-top: 1px solid rgba(255, 255, 255, .1); }
.menu-pied a { color: #fff; text-decoration: none; display: block; padding: 6px 0; }
.menu-pied a.actif { box-shadow: none; background: none; text-decoration: underline; }
.menu-pied .lien { color: var(--menu-texte); padding: 6px 0; }

.contenu { flex: 1; padding: 28px 32px; max-width: 1100px; min-width: 0; }
.contenu.seul { margin: 8vh auto; max-width: 400px; }
h1 { margin: 0 0 20px; font-size: 24px; }
h2 { font-size: 18px; margin: 0 0 12px; }

/* --- Blocs --- */
.carte {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  padding: 20px;
  margin-bottom: 20px;
}
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.chiffre { font-size: 28px; font-weight: 700; }
.chiffre-libelle { color: var(--texte-doux); }
.barre-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.doux { color: var(--texte-doux); }

/* --- Messages --- */
.flash { padding: 12px 16px; border-radius: var(--rayon); margin-bottom: 16px; }
.flash-ok { background: var(--ok-fond); color: var(--ok); }
.flash-erreur { background: var(--erreur-fond); color: var(--erreur); }
.flash-info { background: var(--info-fond); color: var(--accent-fonce); }

.cle {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  background: var(--fond);
  border: 1px dashed var(--accent);
  padding: 12px;
  border-radius: var(--rayon);
  word-break: break-all;
  user-select: all;
}

/* --- Tableaux --- */
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--bordure); vertical-align: middle; }
th { font-size: 13px; color: var(--texte-doux); font-weight: 600; }
tr:last-child td { border-bottom: none; }
.table-carte { border: 1px solid var(--bordure); border-radius: var(--rayon); overflow-x: auto; margin-bottom: 20px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--fond); color: var(--texte-doux); }
.badge-ok { background: var(--ok-fond); color: var(--ok); }
.badge-erreur { background: var(--erreur-fond); color: var(--erreur); }
.badge-accent { background: var(--info-fond); color: var(--accent-fonce); }

/* --- Formulaires --- */
label { display: block; font-weight: 600; margin-bottom: 4px; }
.champ { margin-bottom: 16px; }
.aide { font-size: 13px; color: var(--texte-doux); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], select, textarea {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  border: 1px solid var(--bordure);
  border-radius: 6px;
  background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.case { display: flex; gap: 8px; align-items: center; font-weight: normal; }
.form-etroit { max-width: 520px; }

.bouton, button {
  display: inline-block;
  padding: 9px 16px;
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
}
.bouton:hover, button:hover { background: var(--accent-fonce); border-color: var(--accent-fonce); }
.bouton-secondaire { background: #fff; color: var(--texte); border-color: var(--bordure); }
.bouton-secondaire:hover { background: var(--fond); border-color: var(--bordure); }
.bouton-danger { background: #fff; color: var(--erreur); border-color: var(--erreur); }
.bouton-danger:hover { background: var(--erreur-fond); border-color: var(--erreur); }
button.lien { background: none; border: none; padding: 0; font-weight: normal; cursor: pointer; }
button.lien:hover { background: none; text-decoration: underline; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* --- Médias --- */
.zone-envoi {
  border: 2px dashed var(--bordure);
  border-radius: var(--rayon);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.zone-envoi:hover, .zone-envoi:focus, .zone-envoi.survol { border-color: var(--accent); background: var(--info-fond); outline: none; }
.file-envoi { list-style: none; margin: 12px 0 0; padding: 0; }
.envoi { padding: 8px 0; border-bottom: 1px solid var(--bordure); }
.envoi:last-child { border-bottom: none; }
.envoi-nom { font-weight: 600; word-break: break-all; }
.envoi-barre { height: 6px; background: var(--fond); border-radius: 3px; overflow: hidden; margin: 6px 0 4px; }
.envoi-barre span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.envoi-etat { font-size: 13px; }
.envoi.ok .envoi-barre span { background: var(--ok); }
.envoi.ok .envoi-etat { color: var(--ok); }
.envoi.erreur .envoi-etat { color: var(--erreur); }
.envoi.erreur .envoi-barre { display: none; }

.stockage { margin-top: 16px; }
.stockage-barre { width: 100%; height: 8px; appearance: none; border: none; border-radius: 4px; background: var(--fond); overflow: hidden; }
.stockage-barre::-webkit-progress-bar { background: var(--fond); }
.stockage-barre::-webkit-progress-value { background: var(--accent); }
.stockage-barre::-moz-progress-bar { background: var(--accent); }

.filtres input[type=text] { width: 220px; }

.grille-medias { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.media {
  display: block;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  overflow: hidden;
  color: inherit;
  text-decoration: none;
}
.media:hover { border-color: var(--accent); }
.media-vignette { position: relative; aspect-ratio: 16 / 9; background: #11141b; display: flex; align-items: center; justify-content: center; }
.media-vignette img { width: 100%; height: 100%; object-fit: cover; }
.media-duree { position: absolute; right: 6px; bottom: 6px; background: rgba(0, 0, 0, .75); color: #fff; font-size: 12px; padding: 1px 6px; border-radius: 4px; }
.media-infos { padding: 10px 12px; }
.media-nom { font-weight: 600; margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.fiche-media { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 20px; align-items: start; }
.apercu img, .apercu video { display: block; width: 100%; height: auto; border-radius: 4px; background: #000; }
.apercu .aide { margin-top: 8px; }
table.infos { margin-bottom: 16px; background: none; }
table.infos th { width: 110px; padding-left: 0; }
table.infos td { padding-right: 0; }
code.empreinte { font-size: 12px; }

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

/* --- Formulaires (compléments) --- */
.champ-large { flex: 1; min-width: 240px; width: auto !important; }
.champ-moyen { width: 260px !important; }
.champ-court { width: 100px !important; }
.deux-colonnes { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
button.petit, .bouton.petit { padding: 4px 10px; font-size: 13px; }
fieldset { border: 1px solid var(--bordure); border-radius: var(--rayon); padding: 12px 16px 4px; margin: 0 0 16px; }
legend { font-weight: 600; padding: 0 6px; }
.jours { display: flex; flex-wrap: wrap; gap: 6px 16px; }
input[type=date], input[type=time], input[type=number] {
  padding: 8px 10px;
  font: inherit;
  border: 1px solid var(--bordure);
  border-radius: 6px;
  background: #fff;
}
.deux-colonnes input[type=date], .deux-colonnes input[type=time] { width: 100%; }
/* Programmation : n'afficher que les champs du type choisi */
.form-prog:has(input[name=type][value=recurrent]:checked) .ponctuel,
.form-prog:has(input[name=type][value=ponctuel]:checked) .recurrent { display: none; }
table.horaires input[type=time] { width: 100%; min-width: 96px; }
.form-special:has(input[name=mode][value=ferme]:checked) .plages-speciales { display: none; }
.form-prog:has(input[name=mode_rec][value=ouverture]:checked) .col-heures,
.form-prog:has(input[name=mode_ponc][value=ouverture]:checked) .heures-ponctuel { display: none; }
table.jours-heures { margin-bottom: 8px; background: none; }
table.jours-heures th, table.jours-heures td { padding: 4px 8px 4px 0; border: none; }
table.jours-heures input[type=time] { min-width: 100px; }
table.jours-heures .case { margin: 0; }
.frise-jour .badge { display: block; width: fit-content; margin-top: 2px; font-size: 10px; padding: 0 5px; }

/* --- Playlist --- */
.items { list-style: none; margin: 0 0 16px; padding: 0; counter-reset: item; }
.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  margin-bottom: 6px;
  background: var(--surface);
  counter-increment: item;
}
.item::before { content: counter(item); width: 22px; text-align: right; color: var(--texte-doux); font-size: 13px; }
.item.deplace { opacity: .4; }
.poignee { cursor: grab; color: var(--texte-doux); user-select: none; letter-spacing: -2px; }
.item-vignette { width: 96px; aspect-ratio: 16 / 9; background: #11141b; border-radius: 4px; overflow: hidden; flex-shrink: 0; }
.item-vignette img { width: 100%; height: 100%; object-fit: cover; display: block; }
.item-nom { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.item-duree { font-weight: normal; margin: 0; white-space: nowrap; }
.item-duree input { width: 70px; padding: 4px 6px; }
.item-actions { display: flex; gap: 4px; }
.grille-choix { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.choix { border: 1px solid var(--bordure); border-radius: var(--rayon); overflow: hidden; padding-bottom: 8px; text-align: center; }
.choix-nom { padding: 6px 8px; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Calendrier --- */
.frise-heures, .frise-ligne { display: grid; grid-template-columns: 80px 1fr; align-items: center; }
.frise-heures { grid-template-columns: 80px repeat(8, 1fr); font-size: 12px; color: var(--texte-doux); margin-bottom: 4px; }
.frise-ligne { margin-bottom: 6px; grid-template-rows: auto auto; }
.frise-ligne.aujourdhui .frise-jour { color: var(--accent); font-weight: 700; }
.frise-jour { font-size: 14px; }
.frise { width: 100%; height: 30px; display: block; border-radius: 4px; overflow: hidden; }
.frise-grille { stroke: rgba(255, 255, 255, .5); stroke-width: 1; vector-effect: non-scaling-stroke; }
.frise-maintenant { stroke: var(--erreur); stroke-width: 2; vector-effect: non-scaling-stroke; }
.frise-detail { grid-column: 2; font-size: 13px; }
.frise-detail summary { cursor: pointer; color: var(--texte-doux); }
.frise-detail ul { margin: 4px 0 8px; padding-left: 0; list-style: none; }
.seg-eteint { fill: #3a4150; background: #3a4150; }
.seg-noir { fill: #11141b; background: #11141b; }
.seg-carte { fill: #d6cfc4; background: #d6cfc4; }
.seg-p0 { fill: #c2410c; background: #c2410c; }
.seg-p1 { fill: #2563eb; background: #2563eb; }
.seg-p2 { fill: #15803d; background: #15803d; }
.seg-p3 { fill: #9333ea; background: #9333ea; }
.seg-p4 { fill: #0891b2; background: #0891b2; }
.seg-p5 { fill: #ca8a04; background: #ca8a04; }
.frise-matchs { grid-column: 2; height: 12px; margin-top: 3px; background: var(--fond); }
.seg-match { fill: #e11d48; background: #e11d48; }
.en-ligne { display: inline; }
.apercu-visuel { display: block; width: 240px; margin-top: 8px; border-radius: 4px; }
.actions-match { border-color: var(--accent); }
.pastille { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legende { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; font-size: 13px; color: var(--texte-doux); }

/* --- Mobile --- */
@media (max-width: 760px) {
  .deux-colonnes { grid-template-columns: 1fr; }
  .item { flex-wrap: wrap; }
  .frise-heures, .frise-ligne { grid-template-columns: 48px 1fr; }
  .frise-heures { grid-template-columns: 48px repeat(8, 1fr); font-size: 10px; }
  .app { flex-direction: column; }
  .menu { width: 100%; padding: 12px 0; }
  .menu ul { display: flex; flex-wrap: wrap; }
  .menu li a, .menu li span { padding: 6px 12px; }
  .menu .logo { padding: 0 16px 8px; }
  .menu-pied { display: flex; gap: 16px; padding: 8px 16px 0; }
  .contenu { padding: 20px 16px; }
}
