:root {
  --bg: #0c0c0d;
  --panel: #161617;
  --panel2: #1f1f21;
  --line: #2c2c2f;
  --text: #f2f2f2;
  --muted: #9a9aa0;
  --red: #e10613;
  --red-dark: #a8040e;
  --red-soft: rgba(225, 6, 19, 0.16);
  --ok: #2fbf71;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  display: flex; min-height: 100vh;
}
a { color: #ff5a63; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; margin: 0 0 18px; border-left: 5px solid var(--red); padding-left: 12px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
small { font-size: 12.5px; }

/* Barre latérale */
.side {
  width: 240px; flex: none; background: #000; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 16px; margin-bottom: 22px; }
.brand:hover { text-decoration: none; }
.brand img { width: 42px; height: 42px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px; }
.side .switch { margin-bottom: 14px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.side .switch select { border-color: var(--red); }
.side nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.side nav a { color: #d6d6d9; padding: 9px 12px; border-radius: 8px; border-left: 3px solid transparent; }
.side nav a:hover { background: var(--panel2); text-decoration: none; }
.side nav a.on { background: var(--red-soft); color: #fff; border-left-color: var(--red); }
.pill { background: var(--red); color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 12px; }
.who { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 3px; overflow-wrap: anywhere; }
.who form { margin-top: 8px; }

/* Contenu */
.main { flex: 1; padding: 28px 32px 60px; min-width: 0; }
.main.solo { display: flex; flex-direction: column; align-items: center; padding-top: 8vh; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 18px; }
.card.center { text-align: center; max-width: 480px; margin: 0 auto; }
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--red); border-radius: 12px; padding: 14px 16px; }
.stat b { display: block; font-size: 28px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.logo { width: 84px; height: 84px; object-fit: contain; background: #fff; border-radius: 10px; padding: 4px; }
.logo.small { width: 38px; height: 38px; border-radius: 6px; padding: 2px; vertical-align: middle; }

.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; border: 1px solid; overflow-wrap: anywhere; }
.flash.ok { background: rgba(47, 191, 113, 0.12); border-color: var(--ok); }
.flash.err { background: var(--red-soft); border-color: var(--red); }
.main.solo .flash { width: 100%; max-width: 380px; }

/* Formulaires */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 9px 11px; font: inherit; color: var(--text);
  background: #0f0f10; border: 1px solid var(--line); border-radius: 8px;
}
input[type="checkbox"], input[type="radio"] { display: inline; width: auto; margin: 0 6px 0 0; accent-color: var(--red); }
input[type="file"] { padding: 6px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--red); outline-offset: 1px; border-color: var(--red); }
textarea { min-height: 130px; resize: vertical; }
label.check { color: var(--text); font-size: 14px; }
.cols { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
form.inline { display: inline; }

.btn {
  display: inline-block; background: var(--red); color: #fff; border: 1px solid var(--red); border-radius: 8px;
  padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--red-dark); border-color: var(--red-dark); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--red); color: #fff; }
.btn.danger { background: transparent; color: #ff5a63; border-color: var(--red-dark); }
.btn.danger:hover { background: var(--red-dark); color: #fff; }
.btn.small { padding: 5px 10px; font-size: 13px; font-weight: 500; }

/* Tableaux et listes */
.tablewrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.t td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
ul.list { list-style: none; margin: 0; padding: 0; }
ul.list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
ul.list li:last-child { border-bottom: 0; }
ul.list li.unread { border-left: 3px solid var(--red); padding-left: 10px; }
.badge { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); white-space: nowrap; }
.badge.reservee, .badge.en_attente, .badge.brouillon { border-color: #b8860b; color: #f0c040; }
.badge.scripts_envoyes, .badge.propose { border-color: var(--red); color: #ff7a82; }
.badge.script_valide, .badge.valide, .badge.publiee, .badge.on { border-color: var(--ok); color: var(--ok); }
.badge.refuse, .badge.off { color: var(--muted); }
dl.info { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; overflow-wrap: anywhere; }
.script { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.script.valide { border-color: var(--ok); }
.script pre { white-space: pre-wrap; font: inherit; margin: 8px 0 12px; }

/* Calendrier */
.calnav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 10px; flex-wrap: wrap; }
.calnav h2 { margin: 0; text-transform: capitalize; font-size: 20px; }
.calwrap { overflow-x: auto; }
table.cal { width: 100%; min-width: 760px; border-collapse: collapse; table-layout: fixed; }
table.cal th { padding: 8px; font-size: 12px; text-transform: uppercase; color: var(--muted); background: #000; border: 1px solid var(--line); }
table.cal td { height: 108px; vertical-align: top; padding: 6px; border: 1px solid var(--line); background: var(--panel); }
table.cal td.out { background: #101011; }
table.cal td.out .num { color: #55555a; }
table.cal td.past { opacity: .55; }
table.cal td.today { outline: 2px solid var(--red); outline-offset: -2px; }
.cal .num { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.tag { display: block; font-size: 12px; padding: 3px 6px; border-radius: 6px; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag.pub { background: var(--panel2); color: var(--text); border-left: 3px solid #666; }
.tag.pub.mine { background: var(--red); color: #fff; border-left-color: #fff; font-weight: 600; }
a.tag.pub.reservee { border-left-color: #f0c040; }
a.tag.pub.scripts_envoyes { border-left-color: var(--red); }
a.tag.pub.script_valide, a.tag.pub.publiee { border-left-color: var(--ok); }
.tag.shoot { background: #26262a; color: #ddd; }
.tag.free { border: 1px dashed var(--red); color: #ff7a82; text-align: center; }
.tag.free:hover { background: var(--red); color: #fff; text-decoration: none; }
.tag.idle { color: var(--muted); text-align: center; }
.tag.closed { background: #2a2a2a; color: var(--muted); text-align: center; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: var(--muted); }
.legend .tag { display: inline-block; margin: 0 4px 0 0; }

button.tag { width: 100%; font: inherit; font-size: 12px; cursor: pointer; background: transparent; }
.tag.alert { border: 1px dashed #777; color: var(--muted); text-align: center; }
.tag.alert:hover, .tag.alert.on { border-color: #f0c040; color: #f0c040; }
.cal form { margin: 0; }

/* Statistiques */
.bar { display: inline-block; vertical-align: middle; width: 120px; height: 8px; background: var(--panel2); border-radius: 4px; overflow: hidden; margin-right: 6px; }
.bar span { display: block; height: 100%; background: var(--red); }
summary { cursor: pointer; color: var(--muted); }

/* ---------- Mode jour (le menu latéral reste noir) ---------- */
.themefloat { position: fixed; top: 14px; right: 14px; }
.who [data-theme-toggle] { margin-bottom: 8px; align-self: flex-start; }
:root[data-theme="light"] {
  --bg: #f4f4f6; --panel: #ffffff; --panel2: #f0f0f3; --line: #d8d8de;
  --text: #151517; --muted: #5f5f68; --red-soft: rgba(225, 6, 19, 0.10); --ok: #1c8a4e;
}
[data-theme="light"] .side {
  --panel2: #1f1f21; --line: #2c2c2f; --text: #f2f2f2; --muted: #9a9aa0; --red-soft: rgba(225, 6, 19, 0.16);
  color: var(--text);
}
[data-theme="light"] .main a:not(.btn):not(.tag) { color: #c10510; }
[data-theme="light"] .main input, [data-theme="light"] .main select, [data-theme="light"] .main textarea { background: #fff; }
[data-theme="light"] .main .btn.ghost:hover { color: var(--text); }
[data-theme="light"] .btn.danger { color: #c10510; }
[data-theme="light"] .btn.danger:hover { color: #fff; }
[data-theme="light"] table.cal th { background: #1a1a1c; color: #fff; }
[data-theme="light"] table.cal td.out { background: #ebebef; }
[data-theme="light"] table.cal td.out .num { color: #a3a3ab; }
[data-theme="light"] .tag.shoot { background: #e3e3e8; color: #222; }
[data-theme="light"] .tag.closed { background: #e3e3e8; }
[data-theme="light"] .tag.free { color: #c10510; }
[data-theme="light"] .tag.free:hover { color: #fff; }
[data-theme="light"] .tag.alert:hover, [data-theme="light"] .tag.alert.on { border-color: #9a6b00; color: #9a6b00; }
[data-theme="light"] .badge.reservee, [data-theme="light"] .badge.en_attente, [data-theme="light"] .badge.brouillon { border-color: #9a6b00; color: #9a6b00; }
[data-theme="light"] .badge.scripts_envoyes, [data-theme="light"] .badge.propose { color: #c10510; }
[data-theme="light"] .card, [data-theme="light"] .stat { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06); }

/* Impression / export PDF : fond blanc, sans menu ni boutons */
@media print {
  body { background: #fff; color: #000; display: block; }
  .side, .btn, form, .flash, .legend, .calnav a, .themefloat { display: none !important; }
  .main { padding: 0; }
  .card, .script, table.cal td, table.cal th, .stat { background: #fff !important; color: #000; border-color: #999; }
  .tag, .tag.pub, .tag.pub.mine, .tag.shoot { background: #fff; color: #000; border: 1px solid #999; white-space: normal; }
  a { color: #000; }
  .muted, dl.info dt { color: #444; }
  table.cal { min-width: 0; }
  table.cal td.past { opacity: 1; }
}

/* Cases « e-mails reçus » (équipe, mon compte) */
.mailopts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.row .mailopts { margin: 0; }
.mailopts label.check { margin: 0; white-space: nowrap; }

/* Mention de copyright en bas de chaque page */
.copy { margin-top: 36px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; text-align: center; }
.main.solo .copy { border-top: 0; }
.sidecopy { margin-top: 12px; color: #77777d; font-size: 11.5px; line-height: 1.45; flex-basis: 100%; }

/* Connexion */
.login { width: 100%; max-width: 380px; text-align: center; }
.login h1 { border: 0; padding: 0; margin-bottom: 4px; }
.login .card { text-align: left; margin-top: 18px; border-top: 3px solid var(--red); }
.login .btn { width: 100%; }
.loginlogo { max-width: 130px; max-height: 130px; background: #fff; border-radius: 12px; padding: 6px; margin-bottom: 12px; }

.sidetop { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 22px; }
.sidetop .brand { margin-bottom: 0; min-width: 0; }
.menubtn { display: none; }
.cal .wd { display: none; }

/* ---------- Téléphone et petite tablette ---------- */
@media (max-width: 800px) {
  body { flex-direction: column; }
  .side { width: 100%; height: auto; position: sticky; top: 0; z-index: 20; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line); max-height: 100vh; }
  .sidetop { margin-bottom: 0; }
  .brand { font-size: 15px; }
  .brand img { width: 34px; height: 34px; }
  .menubtn {
    display: inline-block; flex: none; background: transparent; color: #fff; border: 1px solid var(--line); border-radius: 8px;
    padding: 9px 14px; font: inherit; font-weight: 600; cursor: pointer;
  }
  .menubtn[aria-expanded="true"] { border-color: var(--red); }
  /* Menu replié par défaut (si JavaScript est actif), ouvert par le bouton */
  .js .side:not(.open) nav, .js .side:not(.open) .who, .js .side:not(.open) .switch { display: none; }
  html:not(.js) .menubtn { display: none; }
  .side .switch { margin: 12px 0 0; }
  .side nav { margin-top: 12px; gap: 2px; }
  .side nav a { padding: 12px; font-size: 16px; }
  .who { margin-top: 12px; }

  .main { padding: 16px 12px 40px; }
  .main.solo { padding-top: 64px; }
  h1 { font-size: 21px; margin-bottom: 14px; }
  h2 { font-size: 17px; }
  .card { padding: 14px; border-radius: 10px; margin-bottom: 14px; }
  .grid { grid-template-columns: 1fr; gap: 14px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat b { font-size: 22px; }
  .cols { grid-template-columns: 1fr; }
  dl.info { grid-template-columns: 1fr; gap: 0; }
  dl.info dt { font-size: 12.5px; margin-top: 8px; }

  /* 16 px : évite le zoom automatique de l'iPhone à la saisie ; zones tactiles plus hautes */
  input, select, textarea { font-size: 16px; padding: 11px; }
  input[style], select[style] { width: 100% !important; }
  .btn { padding: 11px 16px; }
  .btn.small { padding: 8px 12px; font-size: 14px; }
  label.check { padding: 4px 0; }
  .row > .btn, .row > form > .btn { flex: 1 1 auto; text-align: center; }

  /* Tableaux : défilement horizontal sans écraser les colonnes */
  .tablewrap { margin: 0 -14px; padding: 0 14px; -webkit-overflow-scrolling: touch; }
  table.t { min-width: 520px; }
  table.t th, table.t td { padding: 9px 8px; }

  /* Tableaux contenant des formulaires : une fiche par ligne */
  table.t.stack, table.t.stack tbody, table.t.stack tr, table.t.stack td { display: block; width: 100%; min-width: 0; }
  table.t.stack thead { display: none; }
  table.t.stack tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  table.t.stack tr:last-child { border-bottom: 0; }
  table.t.stack td { padding: 4px 0; border: 0; }
  table.t.stack td:empty { display: none; }

  /* Calendrier : une ligne par jour au lieu d'une grille */
  .calnav { gap: 8px; }
  .calnav h2 { order: -1; width: 100%; text-align: center; font-size: 18px; }
  .calnav a { flex: 1; text-align: center; padding: 9px 6px; font-size: 14px; }
  .calwrap { overflow: visible; }
  table.cal, table.cal tbody, table.cal tr, table.cal td { display: block; width: 100%; min-width: 0; }
  table.cal thead, table.cal td.out { display: none; }
  table.cal td { height: auto; min-height: 0; padding: 10px 12px; border-width: 0 0 1px; display: grid; grid-template-columns: 76px 1fr; column-gap: 10px; align-items: start; }
  table.cal td > * { grid-column: 2; }
  table.cal td > .num { grid-column: 1; grid-row: 1 / span 20; font-size: 14px; margin: 0; padding-top: 6px; text-transform: capitalize; }
  .cal .wd { display: inline; color: var(--muted); font-weight: 500; }
  table.cal td.today { outline-offset: -2px; }
  table.cal td.today .num, table.cal td.today .wd { color: var(--red); }
  .tag { font-size: 14px; padding: 9px 10px; margin-bottom: 5px; white-space: normal; }
  button.tag { font-size: 14px; }
  .legend { gap: 8px 14px; }
  .legend .tag { padding: 3px 8px; font-size: 12px; }
  .themefloat { top: 10px; right: 10px; }
}
