:root {
  --bg: #f4f6fb; --card: #fff; --ink: #172033; --muted: #66708a; --line: #e2e6ef;
  --brand: #1e40af; --brand-2: #3b82f6; --ok: #16a34a; --warn: #f59e0b; --bad: #dc2626;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 14px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.boot { padding: 80px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }

/* ---------- En-tête ---------- */
header.top { position: sticky; top: 0; z-index: 20; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 62px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--brand); white-space: nowrap; }
.logo svg { width: 30px; height: 30px; }
nav.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
nav.tabs button { border: 0; background: none; padding: 9px 14px; border-radius: 10px; color: var(--muted); font-weight: 600; white-space: nowrap; }
nav.tabs button.on { background: #e8eefc; color: var(--brand); }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.who select { border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; background: #fff; max-width: 200px; }
.linkbtn { border: 0; background: none; color: var(--muted); text-decoration: underline; padding: 0; font-size: 13px; }
.dellink { border: 0; background: none; color: var(--bad); text-decoration: underline; padding: 0; font-size: 13px; }

main { max-width: 1280px; margin: 0 auto; padding: 24px 20px 80px; }
h1 { font-size: 22px; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 22px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.btn { border: 1px solid var(--line); background: #fff; padding: 9px 16px; border-radius: 10px; font-weight: 600; }
.btn:hover { border-color: #c5ccdb; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #1b3a9c; }
.btn.big { padding: 13px 22px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: default; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; background: #eef1f6; color: var(--muted); }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }

/* ---------- Écrans ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.screen { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.screen .pv { aspect-ratio: 16/9; background: #0f172a; position: relative; display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 13px; }
.screen .pv img { width: 100%; height: 100%; object-fit: cover; }
.screen .pv .live { position: absolute; left: 10px; top: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: #94a3b8; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(22,163,74,.2); }
.dot.off { background: var(--bad); }
.screen .body { padding: 14px 16px 10px; flex: 1; }
.screen .name { font-weight: 700; font-size: 16px; }
.screen .meta { color: var(--muted); font-size: 13px; margin-top: 3px; }
.screen .foot { display: flex; gap: 8px; padding: 0 12px 12px; }
.screen .foot .btn { flex: 1; }
.iconbtn { width: 42px; flex: 0 0 42px !important; padding: 8px 0; font-size: 18px; line-height: 1; }
.iconbtn.minus { color: var(--bad); }
.add-card { border: 2px dashed #c4cde0; border-radius: var(--radius); background: transparent; min-height: 170px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--brand); font-weight: 700; }
.add-card:hover { background: #eef3ff; border-color: var(--brand-2); }
.add-card .plus { width: 64px; height: 64px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 38px; line-height: 62px; text-align: center; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- Carrousels ---------- */
.cwrap { display: grid; grid-template-columns: 250px 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .cwrap { grid-template-columns: 1fr; } }
.clist { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; }
.clist button.c { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 10px 12px; border-radius: 10px; text-align: left; font-weight: 600; }
.clist button.c.on { background: #e8eefc; }
.clist button.c small { margin-left: auto; color: var(--muted); font-weight: 500; }
.swatch { width: 14px; height: 14px; border-radius: 4px; flex: 0 0 14px; }
.clist .new { width: 100%; margin-top: 6px; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.panel + .panel { margin-top: 18px; }
.panel h2 { font-size: 16px; margin: 0 0 12px; }
.cname { font-size: 20px; font-weight: 700; border: 1px solid transparent; border-radius: 8px; padding: 4px 8px; margin-left: -8px; min-width: 0; flex: 1; }
.cname:hover, .cname:focus { border-color: var(--line); outline: none; }
.colors { display: flex; gap: 6px; }
.colors button { width: 22px; height: 22px; border-radius: 6px; border: 2px solid transparent; }
.colors button.on { border-color: var(--ink); }

.film { display: flex; gap: 12px; overflow-x: auto; padding: 14px; min-height: 182px; background: #0f172a; border-radius: 12px; align-items: flex-start; }
.film.over { outline: 3px dashed var(--brand-2); outline-offset: -3px; }
.film .hint { color: #94a3b8; margin: auto; text-align: center; padding: 20px; }
.slide { flex: 0 0 180px; background: #1e293b; border-radius: 10px; overflow: hidden; color: #e2e8f0; position: relative; cursor: grab; user-select: none; }
.slide.dragging { opacity: .35; }
.slide.drop-before { box-shadow: -4px 0 0 var(--brand-2); }
.slide .th { aspect-ratio: 16/9; background: #000; display: flex; align-items: center; justify-content: center; }
.slide .th img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.slide .n { position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,.65); border-radius: 6px; padding: 1px 7px; font-size: 12px; font-weight: 700; }
.slide .x { position: absolute; right: 6px; top: 6px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 16px; line-height: 1; }
.slide .x:hover { background: var(--bad); }
.slide .dur { display: flex; align-items: center; justify-content: space-between; padding: 7px 8px; font-size: 13px; font-weight: 600; }
.slide .dur button { width: 28px; height: 28px; border-radius: 8px; border: 0; background: #334155; color: #fff; font-size: 17px; line-height: 1; }
.slide .dur button:hover { background: var(--brand-2); }
.vtag { position: absolute; right: 6px; bottom: 44px; background: rgba(0,0,0,.65); font-size: 11px; padding: 1px 6px; border-radius: 5px; }

.drop { border: 2px dashed #c4cde0; border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); margin-bottom: 14px; }
.drop.over { border-color: var(--brand-2); background: #eef3ff; color: var(--brand); }
.drop b { color: var(--brand); }
.lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.lib .m { position: relative; border-radius: 10px; overflow: hidden; background: #0f172a; cursor: grab; aspect-ratio: 16/9; }
.lib .m img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.lib .m .add { position: absolute; right: 6px; bottom: 6px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; font-size: 20px; line-height: 1; }
.lib .m .del { position: absolute; right: 6px; top: 6px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 13px; opacity: 0; }
.lib .m:hover .del { opacity: 1; }
.lib .m .lbl { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 40px 5px 7px; font-size: 11px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.75)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { margin-top: 10px; font-size: 13px; color: var(--brand); }

/* ---------- Planning ---------- */
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 7px 13px; font-weight: 600; }
.days button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.palette { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border-radius: 10px; color: #fff; font-weight: 600; cursor: grab; user-select: none; font-size: 14px; }
.plan { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px 18px; overflow-x: auto; }
.prow { display: grid; grid-template-columns: 170px 1fr; gap: 14px; align-items: center; min-width: 760px; }
.prow + .prow { margin-top: 12px; }
.prow .pn { font-weight: 700; display: flex; flex-direction: column; gap: 2px; }
.prow .pn small { font-weight: 500; color: var(--muted); }
.track { position: relative; height: 58px; border-radius: 10px; background:
  repeating-linear-gradient(135deg, #eef1f6 0 8px, #f7f8fb 8px 16px); border: 1px solid var(--line); }
.track.over { outline: 3px dashed var(--brand-2); }
.track .deflbl { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #9aa3b8; font-size: 12px; pointer-events: none; }
.track .hl { position: absolute; top: 0; bottom: 0; border-left: 1px solid rgba(0,0,0,.06); pointer-events: none; }
.block { position: absolute; top: 4px; bottom: 4px; border-radius: 8px; color: #fff; font-size: 13px; font-weight: 700; padding: 5px 9px;
  overflow: hidden; white-space: nowrap; cursor: grab; box-shadow: 0 2px 6px rgba(0,0,0,.18); user-select: none; }
.block small { display: block; font-weight: 500; opacity: .9; font-size: 11px; }
.block .hd { position: absolute; top: 0; bottom: 0; width: 9px; cursor: ew-resize; }
.block .hd.l { left: 0; } .block .hd.r { right: 0; }
.block .hd::after { content: ""; position: absolute; top: 30%; bottom: 30%; left: 3px; width: 3px; border-radius: 2px; background: rgba(255,255,255,.7); }
.now { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--bad); pointer-events: none; z-index: 3; }
.scale { display: grid; grid-template-columns: 170px 1fr; gap: 14px; min-width: 760px; margin-bottom: 6px; }
.scale .ticks { position: relative; height: 18px; font-size: 11px; color: var(--muted); }
.scale .ticks span { position: absolute; transform: translateX(-50%); }

/* ---------- Fenêtres ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 18px; padding: 24px; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(0,0,0,.25); max-height: 92vh; overflow: auto; }
.modal h3 { margin: 0 0 6px; font-size: 19px; }
.modal p { color: var(--muted); margin: 0 0 16px; }
.modal label { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 6px; }
.modal input[type=text], .modal input[type=email], .modal input[type=password], .modal input[type=number], .modal input[type=time], .modal select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; align-items: center; }
.pin { display: flex; gap: 10px; justify-content: center; margin: 8px 0; }
.pin input { width: 62px; height: 74px; text-align: center; font-size: 34px; font-weight: 800; border: 2px solid var(--line); border-radius: 12px; }
.pin input:focus { border-color: var(--brand); outline: none; }
.switch { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-weight: 600; font-size: 14px; }
.switch input { width: 20px; height: 20px; }
.err { color: var(--bad); font-size: 14px; margin-top: 10px; min-height: 1em; }

.preview { position: fixed; inset: 0; background: #000; z-index: 60; display: flex; align-items: center; justify-content: center; }
.preview .stage { width: min(100vw, calc(100vh * 16 / 9)); aspect-ratio: 16/9; position: relative; background: #000; }
.preview .stage > * { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transition: opacity .5s; }
.preview .close { position: absolute; top: 16px; right: 16px; z-index: 2; }

/* ---------- Connexion ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login .modal { max-width: 400px; }
.login .logo { justify-content: center; font-size: 20px; margin-bottom: 16px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px;
  font-weight: 600; opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 99; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.bad { background: var(--bad); }

table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

/* ---------- Bandeau « client en cours » ---------- */
button.logo { border: 0; background: none; padding: 0; font: inherit; font-weight: 700; color: var(--brand); cursor: pointer; }
.clientbar { position: sticky; top: 62px; z-index: 19; background: linear-gradient(90deg, #1e3a8a, #1e40af 60%, #2563eb); color: #fff; box-shadow: 0 2px 8px rgba(30,64,175,.25); }
.cb-in { max-width: 1280px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.cb-back { border: 1px solid rgba(255,255,255,.4); background: rgba(255,255,255,.12); color: #fff; border-radius: 10px; padding: 8px 14px; font-weight: 600; }
.cb-back:hover { background: rgba(255,255,255,.22); }
.cb-name { display: flex; flex-direction: column; line-height: 1.15; }
.cb-name small { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .8; }
.cb-name b { font-size: 24px; }
.clientbar select { border-radius: 8px; padding: 6px 8px; border: 0; }
.cb-stats { display: flex; gap: 18px; font-size: 14px; opacity: .95; flex-wrap: wrap; }
.cb-stats b { font-size: 17px; }

/* ---------- Accueil admin : cartes clients ---------- */
.ccard { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 10px;
  cursor: pointer; border: 2px solid transparent; transition: border-color .15s, transform .15s; }
.ccard:hover { border-color: var(--brand-2); transform: translateY(-2px); }
.cc-top { display: flex; align-items: flex-start; gap: 10px; justify-content: space-between; }
.cc-name { font-size: 19px; font-weight: 800; color: var(--ink); }
.cc-screens { display: flex; flex-wrap: wrap; gap: 6px; }
.cc-scr { display: inline-flex; align-items: center; gap: 6px; background: #f1f4f9; border-radius: 8px; padding: 4px 9px; font-size: 13px; font-weight: 600; }
.cc-meta, .cc-acc { color: var(--muted); font-size: 13px; }
.cc-go { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.cc-go .btn { padding: 7px 10px; font-size: 13px; }
.cc-go .btn.primary { margin-left: auto; }
.who span { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 700px) { .who span { display: none; } .cb-name b { font-size: 20px; } }

.modal input[type=radio] { width: 18px; height: 18px; }
/* ---------- Médiathèque : dossiers ---------- */
.folders { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.fchip { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 7px 12px; font-weight: 600; font-size: 14px; }
.fchip small { color: var(--muted); font-weight: 600; margin-left: 2px; }
.fchip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.fchip.on small { color: #dbe4ff; }
.fchip.over { outline: 3px dashed var(--brand-2); background: #eef3ff; color: var(--brand); }
.fbar { display: flex; gap: 12px; align-items: center; margin: 0 0 10px; font-size: 14px; }
.lib .m .used { position: absolute; left: 6px; top: 6px; background: rgba(22,163,74,.9); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; }
.lib .m .edit { position: absolute; right: 34px; top: 6px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; opacity: 0; }
.lib .m:hover .edit { opacity: 1; }
.lib .m .lbl small { opacity: .85; }
@media (hover: none) { .lib .m .edit, .lib .m .del { opacity: 1; } }

/* ---------- Admin : arborescence à gauche ---------- */
.shell { display: grid; grid-template-columns: 260px 1fr; min-height: calc(100vh - 62px); }
.side { background: #fff; border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 62px; height: calc(100vh - 62px); overflow-y: auto; }
.side button { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; text-align: left; border-radius: 10px; cursor: pointer; }
.side small { margin-left: auto; color: var(--muted); font-weight: 600; font-size: 12px; }
.nav0 { padding: 11px 12px; font-weight: 800; font-size: 14px; letter-spacing: .04em; color: var(--ink); }
.nav0.on { background: var(--brand); color: #fff; }
.nav0.on small { color: #dbe4ff; }
.tree { margin: 6px 0 0 14px; padding-left: 10px; border-left: 2px solid var(--line); }
.nav1 { padding: 9px 10px; font-weight: 700; font-size: 15px; color: var(--ink); margin-top: 2px; }
.nav1 span:not(.dot) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav1:hover, .nav2:hover, .nav0:not(.on):hover { background: #f1f4f9; }
.nav1.cur { background: #e8eefc; color: var(--brand); }
.sub2 { margin: 2px 0 6px 16px; padding-left: 10px; border-left: 2px solid #c7d4f5; }
.nav2 { padding: 8px 10px; font-weight: 600; font-size: 14px; color: var(--muted); }
.nav2.on { background: var(--brand); color: #fff; }
.nav-new { margin-top: 14px; justify-content: center; border: 1px dashed #c4cde0 !important; color: var(--brand); font-weight: 700; padding: 9px; }
.content { min-width: 0; }
.content .clientbar { top: 62px; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
}
.cb-push { border: 0; background: #fff; color: var(--brand); border-radius: 10px; padding: 9px 16px; font-weight: 800; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.cb-push:hover { background: #e8eefc; }
.cb-push:disabled { opacity: .85; cursor: default; }
.nav-app { margin-top: 18px; padding: 8px 10px; font-size: 13px; color: var(--muted) !important; font-weight: 600; }
.nav-app:hover { background: #f1f4f9; }

/* ---------- Orientation ---------- */
.screen .pv.portrait { aspect-ratio: auto; height: 240px; }
.screen .pv.portrait img { width: auto; height: 100%; aspect-ratio: 9/16; object-fit: cover; }
.rots { display: flex; flex-direction: column; gap: 6px; }
.rot { display: flex !important; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; margin: 0 !important; font-weight: 600; cursor: pointer; }
.rot.on { border-color: var(--brand); background: #eef3ff; }
.rot input { display: none; }
.rot .ico { width: 30px; height: 18px; border: 2.5px solid currentColor; border-radius: 3px; flex: 0 0 auto; }
.rot .ico.p { width: 18px; height: 30px; }
/* « TOUS LES CLIENTS » : simple titre */
div.nav0 { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 13px; cursor: default; border-bottom: 2px solid var(--line); border-radius: 0; padding-bottom: 10px; }
.reco { display: flex; align-items: center; gap: 10px; justify-content: space-between; background: #fef3c7; color: #92400e; border-radius: 10px; padding: 8px 10px; margin: 0 0 8px; font-size: 13px; font-weight: 600; }
.reco .btn { padding: 6px 12px; font-size: 13px; }
.lib .m .del.out { font-size: 15px; }
.bulk { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: #f1f4f9; border-radius: 10px; padding: 8px 12px; margin: 0 0 10px; font-size: 14px; }
.bulk .btn { padding: 5px 12px; }
.bulk small { color: var(--muted); }
.cb-acc { border: 1px solid rgba(255,255,255,.45); background: rgba(255,255,255,.12); color: #fff; border-radius: 10px; padding: 8px 14px; font-weight: 700; }
.cb-acc:hover { background: rgba(255,255,255,.22); }
.appline { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; margin: -6px 0 18px; font-size: 13px; color: var(--muted); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.modal:has(table.t) { max-width: 720px; }
.modal table.t select { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: #fff; }
.btn.danger-txt { color: var(--bad); }
.btn.danger-txt:hover { border-color: #fca5a5; background: #fef2f2; }
.screen .foot .btn { white-space: nowrap; padding: 9px 10px; }
