:root {
  --bg: #f4f5f7; --panel: #fff; --ink: #1c2430; --muted: #6b7584; --line: #e3e6eb; --line2: #f0f2f5;
  --brand: #0f2742; --accent: #ea580c; --accent-ink: #fff; --danger: #dc2626; --warn: #b45309; --ok: #15803d;
  --radius: 8px; --px: 12px; /* hauteur d'un quart d'heure */
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
a.btn { text-decoration: none; color: inherit; }
.week .ws { display: none; }
.hidden { display: none !important; }

/* ---------- barre ---------- */
header.top { background: var(--brand); color: #fff; display: flex; align-items: center; gap: 16px; padding: 0 16px; height: 52px; position: sticky; top: 0; z-index: 50; }
header.top .logo { font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
header.top .logo .ball { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); box-shadow: inset 0 0 0 2px #0f2742, inset 0 0 0 3px var(--accent); position: relative; }
header.top nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
header.top nav a { color: #cbd5e1; text-decoration: none; padding: 7px 12px; border-radius: 6px; white-space: nowrap; }
header.top nav a.active, header.top nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
header.top .user { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
header.top .user button { background: transparent; border: 1px solid rgba(255,255,255,.25); color: #fff; padding: 5px 10px; border-radius: 6px; cursor: pointer; }
main { padding: 16px; max-width: 1500px; margin: 0 auto; }

/* ---------- éléments ---------- */
.btn { border: 1px solid var(--line); background: var(--panel); padding: 7px 12px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: #c7ccd4; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(.95); }
.btn.danger { color: var(--danger); border-color: #f3c4c4; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 8px; font-size: 13px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: var(--line2); }
.chip.warn { background: #fef3c7; color: #92400e; }
.chip.danger { background: #fee2e2; color: #991b1b; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
table.list { width: 100%; border-collapse: collapse; background: var(--panel); }
table.list th, table.list td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* ---------- formulaires ---------- */
.form { display: grid; gap: 12px; }
.form .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form .grid3 { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 12px; }
label.f { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.f > span { font-weight: 600; }
input[type=text], input[type=password], input[type=date], select, textarea {
  width: 100%; border: 1px solid #cfd4db; border-radius: 6px; padding: 8px 10px; background: #fff; color: var(--ink);
}
textarea { min-height: 60px; resize: vertical; }
input[type=color] { width: 44px; height: 36px; border: 1px solid #cfd4db; border-radius: 6px; padding: 2px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #fdba74; outline-offset: 0; border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); cursor: pointer; }
.seg { display: inline-flex; border: 1px solid #cfd4db; border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 7px 12px; cursor: pointer; border-right: 1px solid #cfd4db; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--brand); color: #fff; }
.box { background: var(--line2); border-radius: 6px; padding: 10px 12px; }
.hint { font-size: 12px; color: var(--muted); }
.scope { display: grid; gap: 6px; }

/* ---------- modale ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; z-index: 100; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 10px; width: 100%; max-width: 560px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal header { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal header h2 { margin: 0; flex: 1; }
.modal .body { padding: 18px; }
.modal footer { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.err { background: #fee2e2; color: #991b1b; padding: 9px 12px; border-radius: 6px; font-size: 13px; }
.conflicts { background: #fef3c7; color: #78350f; padding: 10px 12px; border-radius: 6px; font-size: 13px; }
.conflicts ul { margin: 6px 0 0; padding-left: 18px; max-height: 180px; overflow-y: auto; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,.2); }

/* ---------- connexion ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #0f2742, #1e3a5f 60%, #ea580c 140%); }
.login .card { width: 100%; max-width: 360px; padding: 26px; }
.login h1 { display: flex; gap: 10px; align-items: center; }

/* ---------- planning ---------- */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .week { font-weight: 700; font-size: 16px; min-width: 190px; text-align: center; }
.toolbar select { width: auto; min-width: 150px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 0 0 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg-block { width: 16px; height: 12px; border: 1px dashed #94a3b8; background: #fff; border-radius: 3px; }
.lg-slot { width: 16px; height: 12px; background: var(--accent); border-radius: 3px; }
.lg-closed { width: 16px; height: 12px; border-radius: 3px; background: repeating-linear-gradient(45deg, #fecaca 0 4px, #fff 4px 8px); }

.grid { display: grid; grid-template-columns: 52px repeat(7, minmax(110px, 1fr)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 190px); }
.grid .head { position: sticky; top: 0; z-index: 6; background: var(--panel); border-bottom: 1px solid var(--line); padding: 6px; text-align: center; min-height: 44px; }
.grid .head.corner { left: 0; z-index: 7; }
.grid .head .d { font-weight: 700; }
.grid .head.today .d { color: var(--accent); }
.grid .head .closed { display: block; margin-top: 3px; font-size: 11px; color: #991b1b; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid .times { position: sticky; left: 0; z-index: 5; background: var(--panel); border-right: 1px solid var(--line); }

.grid .times div { height: calc(var(--px) * 4); font-size: 11px; color: var(--muted); text-align: right; padding-right: 6px; transform: translateY(-7px); }
  .grid .times div:first-child { transform: none; }
.grid .day { position: relative; border-right: 1px solid var(--line2);
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(var(--line2) 1px, transparent 1px);
  background-size: 100% calc(var(--px) * 4), 100% calc(var(--px) * 2); }
.grid .day.editable { cursor: copy; }
.grid .day.weekend { background-color: #fafbfc; }
.block { position: absolute; border: 1.5px dashed var(--gc, #94a3b8); border-radius: 6px; background: color-mix(in srgb, var(--gc, #94a3b8) 7%, #fff); overflow: hidden; cursor: pointer; }
.block.closed { background: repeating-linear-gradient(45deg, #fee2e2 0 6px, #fff 6px 12px); border-color: #ef4444; }
.block .bl { position: absolute; right: 4px; bottom: 2px; font-size: 10px; color: var(--muted); white-space: nowrap; max-width: calc(100% - 8px); overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.block:hover { box-shadow: 0 0 0 2px color-mix(in srgb, var(--gc, #94a3b8) 40%, transparent); }
.slot { position: absolute; border-radius: 5px; padding: 3px 5px; color: #fff; font-size: 11.5px; line-height: 1.25; overflow: hidden; cursor: pointer; background: var(--tc); border-left: 4px solid color-mix(in srgb, var(--tc) 60%, #000); box-shadow: 0 1px 2px rgba(0,0,0,.15); z-index: 2; }
.slot b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.slot .s { opacity: .92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.slot.match { background: repeating-linear-gradient(135deg, var(--tc) 0 8px, color-mix(in srgb, var(--tc) 85%, #000) 8px 16px); }
.slot.closed { outline: 2px solid #ef4444; outline-offset: 1px; }
.slot:hover { filter: brightness(1.07); z-index: 3; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: #ef4444; z-index: 4; pointer-events: none; }

/* vue liste */
.daylist { display: grid; gap: 10px; }
.daylist .dl { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.daylist .dl > h3 { margin: 0; padding: 9px 12px; font-size: 14px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.daylist .dl.today > h3 { color: var(--accent); }
.li-block { padding: 8px 12px; border-bottom: 1px solid var(--line2); border-left: 4px solid var(--gc); }
.li-block:last-child { border-bottom: 0; }
.li-block .bh { display: flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; flex-wrap: wrap; }
.li-slot { display: flex; gap: 10px; align-items: center; margin: 6px 0 0 6px; padding: 6px 8px; border-radius: 6px; background: var(--line2); cursor: pointer; flex-wrap: wrap; }
.li-slot .time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 92px; }
.li-free { margin: 6px 0 0 6px; font-size: 12px; color: var(--ok); cursor: pointer; }

/* gymnases */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.gym-card h2 { display: flex; align-items: center; gap: 8px; }
#jump { width: auto; }
.cform { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.cform .full { grid-column: 1 / -1; justify-content: center; }
[data-force] { margin: 8px 0 4px; font-weight: 600; color: #78350f; }
.closure { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line2); flex-wrap: wrap; }

@media (max-width: 760px) {
  main { padding: 10px; }
  header.top { gap: 8px; padding: 0 10px; }
  header.top .logo span.t { display: none; }
  header.top .user .name { display: none; }
  .toolbar .week { min-width: 0; flex: 1; font-size: 14px; white-space: nowrap; }
  #jump { display: none; }
  .week .wl { display: none; } .week .ws { display: inline; }
  .toolbar .spacer { display: none; }
  .toolbar select { flex: 1 1 calc(50% - 8px); min-width: 40% !important; }
  .toolbar .week { flex: 1 0 auto; }
  .row > h1 + .spacer + .btn { padding: 6px 9px; }
  .legend .muted { display: none; }
  .form .grid2, .form .grid3 { grid-template-columns: 1fr; }
  .toolbar select { min-width: 0; flex: 1; }
}
