/* Design system « TimeTrack Flow » : neutres ink/paper, accent orange, PP Mori + Graebenbach Mono
   (si installées sur le poste, sinon Inter / DM Mono). */
:root {
  --bg: #eeeeee;          /* neutral-paper */
  --surface: #ffffff;     /* neutral-white */
  --paper: #eeeeee;
  --ink: #121212;         /* neutral-ink */
  --muted: #5f5f5f;       /* neutral-600 */
  --faint: #9a9a9a;       /* neutral-400 */
  --line: #c4c4c4;        /* neutral-200 */
  --line-soft: #d9d9d9;   /* UI/200 */
  --ui-20: rgba(18,18,18,.2);
  --accent: #ed5b36;      /* accent-600 */
  --accent-25: #fef7f5;
  --danger: #e11d48;
  --ok: #059669;
  --warn: #daa03e;
  --info: #3b82f6;
  --radius: 4px;
  --font: "PP Mori", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "Graebenbach Mono", "DM Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --pw: 140px; /* largeur d'une page sur le tableau */
  --ratio: 0.7667;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; }
body.no-scroll { overflow: hidden; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); }
.print-only { display: none; }

/* Boutons ------------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #bdbcb4; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary.danger, .btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,.05); }
.btn.light { color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.link { border: 0; background: none; padding: 0; color: var(--ink); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; font-size: 12px; }
.link.danger { color: var(--danger); }
input:not([type=range]):not([type=color]):not([type=checkbox]), select, textarea {
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: -1px; }

.logo { display: inline-flex; gap: 2px; }
.logo span { width: 10px; height: 16px; background: var(--ink); }
.logo span + span { background: var(--accent); }

/* Connexion ---------------------------------------------------------------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--surface); padding: 40px; border-radius: 14px; text-align: center; width: min(380px, 100%); box-shadow: 0 10px 40px rgba(0,0,0,.08); }
.login-card h1 { margin: 14px 0 6px; font-size: 24px; }
.auth-form { display: grid; gap: 8px; margin-top: 20px; text-align: left; }
.auth-form .btn { justify-content: center; }

/* Barre du haut ------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 12px 20px; background: rgba(241,240,236,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 17px; }
.stats { flex: 1; min-width: 200px; max-width: 460px; }
.progress { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--line); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.tools { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.zoom { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.zoom-btn { width: 32px; justify-content: center; padding: 6px 0; font-size: 16px; line-height: 1; }
.user { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px; border-radius: 20px; }
.user:hover { background: rgba(0,0,0,.05); }
.user img, .avatar { width: 26px; height: 26px; border-radius: 50%; }
.avatar { display: grid; place-items: center; background: var(--ink); color: #fff; font-size: 11px; font-weight: 600; }

.selection-bar {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 25;
  width: max-content; max-width: calc(100vw - 32px);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; background: var(--ink); color: #fff; border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
.selection-bar select { width: auto; color: var(--ink); }
.selection-bar .btn { color: var(--ink); }
.selection-bar .btn.ghost { color: #fff; }

.swatches { display: flex; gap: 4px; flex-wrap: wrap; }
.swatches button { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatches button.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.swatches button.none { background: var(--surface); border: 1px dashed var(--muted); color: var(--muted); font-size: 11px; line-height: 1; }

/* Tableau (planches) ------------------------------------------------------- */
.board {
  display: flex; flex-wrap: wrap; gap: 28px 26px; padding: 24px 20px 12px;
  align-items: flex-start;
}
.spread { display: flex; }
.slot { width: var(--pw); }
.hint { padding: 0 20px 110px; }

.page { position: relative; cursor: pointer; user-select: none; }
.page .sheet {
  position: relative; aspect-ratio: var(--ratio); background: var(--surface);
  display: grid; place-items: center; overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 0 0 1px rgba(0,0,0,.04);
  border-bottom: 4px solid var(--status);
  transition: transform .12s, box-shadow .12s;
}
.page.left .sheet { box-shadow: inset -8px 0 10px -8px rgba(0,0,0,.18), 0 1px 2px rgba(0,0,0,.12); }
.page.right .sheet { box-shadow: inset 8px 0 10px -8px rgba(0,0,0,.18), 0 1px 2px rgba(0,0,0,.12); }
.page:hover .sheet { transform: translateY(-2px); }
/* Filet gris au pli d'une double page (sur le bord intérieur de la page de gauche). */
.spread .page.left:has(+ .page) .sheet::after {
  content: ""; position: absolute; top: 0; bottom: 0; right: 0; width: 1px;
  background: #7d7d78; z-index: 2; pointer-events: none;
}
.page .sheet img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.page .empty-title { padding: 8px; text-align: center; font-size: 12px; color: var(--muted); word-break: break-word; }
.page .rubric { position: absolute; top: 0; left: 0; right: 0; height: 5px; z-index: 1; }
.page.selected .sheet { outline: 3px solid var(--ink); outline-offset: 2px; }
.page.dragging { opacity: .35; }
.page.drop-target .sheet { outline: 3px dashed var(--ink); outline-offset: 3px; transform: scale(1.03); }
.page.drop-target.drop-files .sheet { outline-color: var(--accent); }

.badge {
  position: absolute; z-index: 2; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; font-size: 10.5px; font-weight: 700; line-height: 18px; text-align: center;
}
.badge.comments { top: 8px; right: 6px; background: var(--accent); color: #fff; }
.badge.presence { top: 8px; left: 6px; background: var(--ink); color: #fff; }
.badge.versions { bottom: 4px; left: 5px; background: rgba(255,255,255,.9); color: var(--ink); border: 1px solid var(--line); }
.menu-btn {
  position: absolute; bottom: 4px; right: 4px; z-index: 2; opacity: 0;
  width: 24px; height: 20px; border-radius: 4px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; line-height: 1;
}
.page:hover .menu-btn, .menu-btn:focus { opacity: 1; }

/* Articles : une ligne fixe par article sur tout le chemin de fer, nom sur sa première page. */
.lanes { margin-top: 4px; }
.lane { position: relative; height: 16px; }
.lane i { display: block; height: 3px; }
.lane span {
  position: absolute; top: 4px; left: 0; z-index: 1; white-space: nowrap; pointer-events: none;
  font-size: 10.5px; line-height: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 10px; border-radius: 14px; border: 1.5px solid var(--c); background: var(--surface); color: var(--ink); cursor: pointer; font-size: 12px; }
.chip.on { background: var(--c); color: #fff; font-weight: 600; }
.meta { display: flex; align-items: baseline; gap: 5px; margin-top: 3px; font-size: 12px; padding: 0 2px; }
.meta .num { font-weight: 700; font-variant-numeric: tabular-nums; }
.meta .sel { margin: 0; width: 13px; height: 13px; flex: none; align-self: center; cursor: pointer; accent-color: var(--ink); }
.meta .title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.meta .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; align-self: center; }

/* Menus contextuels -------------------------------------------------------- */
.menu {
  position: absolute; z-index: 1000; min-width: 200px; padding: 4px;
  background: var(--surface); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0,0,0,.18);
}
.menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; border-radius: 5px; cursor: pointer; }
.menu button:hover { background: var(--bg); }
.menu button.danger { color: var(--danger); }

/* Panneau activité --------------------------------------------------------- */
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 100%); z-index: 30;
  background: var(--surface); box-shadow: -10px 0 40px rgba(0,0,0,.1); display: flex; flex-direction: column;
}
.panel header { display: flex; justify-content: space-between; align-items: center; padding: 16px; border-bottom: 1px solid var(--line); }
.panel ol { list-style: none; margin: 0; padding: 8px 16px; overflow: auto; }
.panel li { padding: 8px 0; border-bottom: 1px solid var(--bg); line-height: 1.4; }
.panel time { display: block; font-size: 11px; color: var(--muted); }

/* Boîtes de dialogue ------------------------------------------------------- */
dialog { border: 0; border-radius: 12px; padding: 0; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(20,20,18,.55); }
.form-dialog { width: min(480px, calc(100vw - 32px)); }
.form-dialog.wide { width: min(820px, calc(100vw - 32px)); }
.form-dialog form, #importBody { padding: 22px; display: grid; gap: 14px; }
.form-dialog label { display: grid; gap: 5px; font-size: 12px; color: var(--muted); }
.form-dialog .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-dialog h3 { font-size: 13px; margin-top: 6px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.groups { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.groups li { display: grid; grid-template-columns: 32px 1fr auto auto; gap: 8px; align-items: center; }
.groups input[type=color] { width: 32px; height: 32px; border: 0; padding: 0; background: none; cursor: pointer; }

.table-wrap { max-height: 50vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.import-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.import-table td { padding: 7px 10px; border-bottom: 1px solid var(--bg); }
.import-table .arrow { color: var(--muted); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.tag.ok { background: #e3f4ec; color: var(--ok); }
.tag.warn { background: #fdf1d6; color: #9a6700; }
.progress-wrap .bar { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.progress-wrap .bar span { display: block; height: 100%; width: 0; background: var(--ink); transition: width .2s; }

/* Comptes ---------------------------------------------------------------- */
.users-body { padding: 22px; display: grid; gap: 16px; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
.users-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.users-table td { padding: 8px 6px; border-bottom: 1px solid var(--bg); }
.users-table td:last-child { text-align: right; white-space: nowrap; }
.users-table .link + .link { margin-left: 10px; }
.user-form { display: grid; gap: 8px; }
.user-form h3 { font-size: 13px; }
.row3 { display: grid; grid-template-columns: 1.3fr 1fr auto auto; gap: 8px; align-items: center; }
.form-dialog label.check, .check { display: flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.credentials { background: #e3f4ec; border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 6px; }
.credentials code { font-size: 15px; font-weight: 700; user-select: all; }
@media (max-width: 640px) { .row3 { grid-template-columns: 1fr; } }

/* Page en grand ------------------------------------------------------------ */
.page-dialog {
  width: calc(100vw - 32px); height: calc(100vh - 32px); max-width: 1500px; max-height: none;
  display: none; grid-template-columns: 1fr 360px; background: var(--bg);
}
.page-dialog[open] { display: grid; }
.viewer { position: relative; display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; padding: 20px 56px; }
.stage { position: relative; height: 100%; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.stage.drop-target { outline: 3px dashed var(--accent); outline-offset: -8px; border-radius: 10px; }
.spread-box { flex: 1 1 0; min-height: 0; width: 100%; container-type: size; display: flex; align-items: center; justify-content: center; }
.spread-lg {
  display: flex; box-shadow: 0 4px 30px rgba(0,0,0,.15);
  width: min(100cqw, 100cqh * var(--sr)); height: min(100cqh, 100cqw / var(--sr));
}
.sheet-lg { position: relative; flex: var(--r) 1 0; min-width: 0; height: 100%; background: var(--surface); cursor: crosshair; }
.sheet-lg.unfocused { cursor: pointer; }
.sheet-lg.unfocused > img, .sheet-lg.unfocused > .empty, .sheet-lg.unfocused > .pin { opacity: .45; transition: opacity .15s; }
.sheet-lg.unfocused:hover > img, .sheet-lg.unfocused:hover > .empty, .sheet-lg.unfocused:hover > .pin { opacity: .75; }
.sheet-lg + .sheet-lg::before { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 1px; background: #7d7d78; z-index: 3; }
.sheet-lg img { width: 100%; height: 100%; object-fit: contain; display: block; user-select: none; }
.sheet-lg .empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: var(--muted); font-size: 18px; }
.stage-hint { margin: 0; }
.banner { background: #fdf1d6; color: #7a5200; padding: 6px 12px; border-radius: 6px; font-size: 13px; }
.nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 3;
  width: 40px; height: 64px; border: 0; border-radius: 8px; background: rgba(255,255,255,.7); font-size: 30px; cursor: pointer; color: var(--ink);
}
.nav:hover { background: #fff; }
.nav.prev { left: 8px; }
.nav.next { right: 8px; }

.pin {
  position: absolute; z-index: 3; transform: translate(-50%, -50%);
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff; border: 2px solid #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.35); padding: 0;
}
.pin:hover { transform: translate(-50%, -50%) scale(1.15); }
.pin[data-comment] { cursor: grab; touch-action: none; }
.pin.dragging { cursor: grabbing; transform: translate(-50%, -50%) scale(1.25); box-shadow: 0 6px 16px rgba(0,0,0,.4); z-index: 5; }
.pin.resolved { background: var(--muted); opacity: .7; }
.pin.other { background: #9a7a6f; }
.pin.draft { background: var(--ink); }
.pin-form {
  position: absolute; z-index: 4; width: 260px; margin: 8px 0 0 -130px;
  background: var(--surface); padding: 10px; border-radius: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.25);
  display: grid; gap: 8px; cursor: default;
}
.pin-form div { display: flex; justify-content: flex-end; gap: 6px; }

.side { background: var(--surface); overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.side header { display: flex; justify-content: space-between; align-items: flex-start; }
.big-label { font-size: 28px; font-weight: 750; letter-spacing: -0.02em; }
.presence-note { background: #eef3fb; color: #25508f; padding: 7px 10px; border-radius: 6px; font-size: 13px; }
.field { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
.segs { display: flex; gap: 4px; flex-wrap: wrap; }
.seg { flex: 1; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); cursor: pointer; font-size: 12px; color: var(--ink); }
.seg.on { background: var(--c); border-color: var(--c); color: #fff; font-weight: 600; }
.side section { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 8px; }
.side h3 { font-size: 13px; display: flex; align-items: center; gap: 8px; }
.count { background: var(--bg); border-radius: 9px; padding: 0 7px; font-size: 11px; color: var(--muted); }
.side h3 .link { margin-left: auto; font-weight: 400; }
.comments, .versions { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.comments li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 8px; border-radius: 6px; background: var(--bg); transition: background .3s; }
.comments li.resolved { opacity: .6; }
.comments li.flash { background: #fde3d9; }
.comments p { margin: 4px 0; line-height: 1.4; word-break: break-word; }
.comments .c-actions { display: flex; gap: 10px; align-items: center; }
.pin-num { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.resolved .pin-num { background: var(--muted); }
.versions li { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 6px; border-radius: 6px; }
.versions li.current { background: #f3faf6; }
.versions li.viewed { outline: 1px solid var(--ink); }
.versions img { width: 44px; height: 58px; object-fit: contain; background: var(--bg); }
.versions .v-actions { display: grid; gap: 4px; justify-items: end; }
.btn.upload { justify-content: center; }

/* Liseuse ------------------------------------------------------------------ */
.reader { position: fixed; inset: 0; z-index: 50; background: #1b1b1a; display: flex; align-items: center; justify-content: center; }
.reader-spread { display: flex; height: calc(100vh - 110px); max-width: calc(100vw - 120px); }
.r-page { height: 100%; aspect-ratio: var(--ratio); background: #fff; display: grid; place-items: center; cursor: zoom-in; overflow: hidden; }
.r-page.blank { background: transparent; cursor: default; }
.r-page { position: relative; }
.r-page:not(.blank) + .r-page:not(.blank)::before { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 1px; background: #7d7d78; z-index: 1; }
.r-page img { width: 100%; height: 100%; object-fit: contain; }
.r-page span { color: var(--muted); }
.reader-bar { position: absolute; bottom: 14px; left: 0; right: 0; display: flex; justify-content: center; align-items: center; gap: 20px; color: #ddd; }
.reader .nav { background: rgba(255,255,255,.12); color: #fff; }

/* Notifications ------------------------------------------------------------ */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 2000; display: grid; gap: 8px; justify-items: center; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.2); transition: opacity .4s; max-width: min(520px, calc(100vw - 32px)); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--ok); }
.toast.out { opacity: 0; }
.fatal { padding: 40px; text-align: center; color: var(--danger); }

/* Mobile ------------------------------------------------------------------- */
@media (max-width: 820px) {
  .topbar { padding: 10px 16px; gap: 10px; }
  .board { padding: 16px; gap: 20px 16px; }
  .page-dialog { grid-template-columns: 1fr; grid-template-rows: 55vh auto; overflow: auto; width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
  .viewer { padding: 12px 44px; }
}

/* Impression : export du chemin de fer ------------------------------------- */
/* ---------------------------------------------------------------------------
   Habillage TimeTrack Flow
   --------------------------------------------------------------------------- */
body { font-size: 14px; line-height: 1.3; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-weight: 400; letter-spacing: 0; }
.small { font-size: 12px; line-height: 14px; }

/* Boutons : mono majuscule, bord ink fin */
.btn {
  font-family: var(--mono); font-size: 12px; line-height: 12px; text-transform: uppercase; letter-spacing: .02em;
  padding: 7px 10px; border: 1px solid var(--ink); border-radius: var(--radius); background: var(--surface); color: var(--ink);
}
.btn:hover { background: var(--paper); border-color: var(--ink); }
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover { background: #2a2a2a; }
.btn.primary.danger, .btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--ui-20); }
.link { font-size: 12px; text-underline-offset: 3px; }

/* Champs : fond paper, bord neutre, focus ink */
input:not([type=range]):not([type=color]):not([type=checkbox]), select, textarea {
  background: var(--paper); border: 1px solid var(--faint); border-radius: var(--radius);
  padding: 8px 11px; font-size: 16px; line-height: 18px; color: var(--ink);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; }
input[type=checkbox] { accent-color: var(--accent); }

/* Libellés de champs : mono majuscule */
.form-dialog label, .field, .auth-form p, .user-form h3, .form-dialog h3 {
  font-family: var(--mono); font-size: 11px; line-height: 12px; text-transform: uppercase; letter-spacing: .02em; color: var(--muted);
}
.form-dialog label input, .form-dialog label select, .field input, .field select { font-family: var(--font); text-transform: none; letter-spacing: 0; }
.field .small { text-transform: none; font-family: var(--font); }

/* Barre du haut */
.topbar { background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); padding: 10px 20px; }
.brand h1 { font-size: 16px; line-height: 18px; }
#issueMeta { font-family: var(--mono); font-size: 11px; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.progress { height: 4px; border-radius: 0; background: var(--line-soft); }
.legend { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .02em; }
.user { border-radius: var(--radius); }
.avatar { background: var(--faint); font-family: var(--mono); font-size: 10px; }
.logo span + span { background: var(--accent); }

/* Tableau */
.board { background: var(--bg); }
.page .sheet { box-shadow: 0 0 0 1px var(--line-soft); }
.page.left .sheet, .page.right .sheet { box-shadow: 0 0 0 1px var(--line-soft); }
.meta { font-size: 12px; }
.meta .num { font-family: var(--mono); font-weight: 400; font-size: 12px; }
.meta .title { color: var(--muted); }
.lane span { font-family: var(--mono); font-weight: 400; font-size: 10.5px; }
.badge { font-family: var(--mono); font-weight: 400; border-radius: var(--radius); }
.badge.comments { background: var(--accent); }
.menu-btn { border-color: var(--ink); border-radius: var(--radius); }
.page.selected .sheet { outline: 2px solid var(--accent); }
.page.drop-target .sheet { outline-color: var(--ink); }
.hint { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .02em; }

/* Barre de sélection (fixe en bas) */
.selection-bar { border-radius: var(--radius); background: var(--ink); }
.selection-bar strong { font-family: var(--mono); font-weight: 400; text-transform: uppercase; font-size: 12px; }
.selection-bar select { background: #fff; font-size: 13px; padding: 6px 8px; border-color: #fff; }
.selection-bar .btn { background: #fff; border-color: #fff; }
.selection-bar .btn.ghost { background: transparent; border-color: transparent; color: #fff; }

/* Menus contextuels */
.menu { border-radius: var(--radius); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(18,18,18,.12); }
.menu button { border-radius: 2px; }

/* Fenêtres : fond paper, bord neutre, titre regular */
dialog { border-radius: 8px; border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(18,18,18,.25); }
dialog::backdrop { background: rgba(18,18,18,.4); }
.form-dialog { background: var(--paper); }
.form-dialog h2, #importBody h2, .users-body h2 { font-size: 16px; line-height: 18px; font-weight: 400; }
.form-dialog input:not([type=checkbox]):not([type=color]), .form-dialog select { background: var(--surface); }
.table-wrap { border-color: var(--line); border-radius: var(--radius); background: var(--surface); }
.import-table td, .users-table td { border-bottom-color: var(--line); }
.users-table { background: var(--surface); border-radius: var(--radius); }

/* Étiquettes (tags) : mono majuscule, bord fin */
.tag { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .02em; border-radius: var(--radius); background: transparent; border: 1px solid var(--faint); color: var(--muted); }
.tag.ok { background: transparent; border-color: var(--ok); color: var(--ok); }
.tag.warn { background: transparent; border-color: var(--warn); color: #9a6a12; }
.count { font-family: var(--mono); border-radius: var(--radius); background: var(--paper); }

/* Alertes / encarts : bord coloré, fond blanc */
.credentials { background: var(--surface); border: 1px solid var(--ok); color: var(--ok); border-radius: var(--radius); }
.credentials code { color: var(--ink); font-family: var(--mono); }
.banner { background: var(--surface); border: 1px solid var(--warn); color: #9a6a12; border-radius: var(--radius); }
.presence-note { background: var(--surface); border: 1px solid var(--info); color: var(--info); border-radius: var(--radius); }
.error { color: var(--danger); }

/* Notifications */
.toast { border-radius: var(--radius); background: var(--surface); color: var(--ink); border: 1px solid var(--ink); box-shadow: 0 8px 24px rgba(18,18,18,.15); }
.toast.error { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.toast.success { background: var(--surface); color: var(--ok); border-color: var(--ok); }

/* Page en grand */
.page-dialog { background: var(--paper); }
.side { background: var(--surface); border-left: 1px solid var(--line); }
.big-label { font-family: var(--mono); font-size: 24px; font-weight: 400; }
.side h3 { font-family: var(--mono); font-size: 11px; font-weight: 400; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); }
.side section { border-top-color: var(--line); }
.seg { font-family: var(--mono); font-size: 11px; text-transform: uppercase; border-color: var(--ink); border-radius: var(--radius); }
.seg.on { color: #fff; }
.chip { font-family: var(--mono); font-size: 11px; text-transform: uppercase; border-radius: var(--radius); }
.comments li { background: var(--paper); border-radius: var(--radius); }
.comments li.flash { background: var(--accent-25); box-shadow: 0 0 0 1px var(--accent) inset; }
.pin, .pin-num { background: var(--accent); }
.pin-form { border-radius: var(--radius); border: 1px solid var(--line); }
.versions li { border-radius: var(--radius); }
.versions li.current { background: var(--paper); }
.versions li.viewed { outline-color: var(--ink); }
.nav { background: var(--surface); border: 1px solid var(--ink); border-radius: var(--radius); width: 36px; height: 36px; font-size: 22px; }
.nav:hover { background: var(--paper); }

/* Panneau activité */
.panel { border-left: 1px solid var(--line); }
.panel h2 { font-size: 16px; font-weight: 400; }
.panel time { font-family: var(--mono); text-transform: uppercase; font-size: 10.5px; }

/* Connexion */
.login { background: var(--bg); }
.login-card { border-radius: 8px; border: 1px solid var(--line); box-shadow: none; }
.login-card h1 { font-size: 20px; font-weight: 400; }

/* États vides : encadré pointillé, texte centré */
.groups li.empty-state, .comments li.empty-state {
  display: block; grid-template-columns: none; padding: 14px 16px; text-align: center;
  border: 1px dashed var(--faint); border-radius: var(--radius); background: transparent;
  font-family: var(--font); font-size: 14px; line-height: 18px; color: var(--ink); text-transform: none; letter-spacing: 0;
}
.groups li.empty-state span, .comments li.empty-state span { display: inline-block; margin-top: 4px; font-size: 12px; line-height: 14px; color: var(--muted); }

/* Impressions & papiers */
.specs { margin-top: 1px; padding: 0 2px; font-family: var(--mono); font-size: 10px; line-height: 12px; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); }
.specs span { display: block; height: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.specs-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.specs-list li[data-id] { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; }
.specs-list li.empty-state {
  padding: 10px 14px; text-align: center; border: 1px dashed var(--faint); border-radius: var(--radius);
  font-family: var(--font); font-size: 14px; color: var(--ink); text-transform: none; letter-spacing: 0;
}
.specs-list li.empty-state span { font-size: 12px; color: var(--muted); }
.spec-add { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.form-dialog .spec-add input { background: var(--surface); }
#settingsDialog form { max-height: calc(100vh - 60px); overflow: auto; }
@media print { .specs { font-size: 5.5pt; line-height: 1.2; } .specs span { height: auto; } }

/* Formats de page variables & surcouverture */
.slot { width: calc(var(--pw) * var(--sw, 1)); }
.page .sheet { aspect-ratio: var(--r, var(--ratio)); }
.spread.jacket { margin-right: 18px; padding-right: 26px; border-right: 1px dashed var(--faint); }
.page.solo .sheet { box-shadow: 0 0 0 1px var(--line-soft); }

/* Cahiers : numéro discret, alterné clair/foncé pour voir l'emboîtement */
.meta .cahier {
  margin-left: auto; flex: none; min-width: 16px; padding: 0 4px; border-radius: 2px; text-align: center;
  font-family: var(--mono); font-size: 10px; line-height: 14px; border: 1px solid var(--faint); color: var(--muted);
}
.meta .cahier.c1 { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.meta .title + .cahier, .meta .warn-flag + .cahier { margin-left: 4px; }
.warn-flag { color: var(--warn); font-size: 12px; flex: none; }
.sheet-note { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); }
.binding-summary { margin: 0; font-size: 12px; color: var(--muted); }
.warn-text { color: #9a6a12; }
[data-theme="dark"] .warn-text { color: #e6b866; }
.form-dialog label.check { font-family: var(--font); font-size: 14px; text-transform: none; letter-spacing: 0; color: var(--ink); }
@media print { .spread.jacket { border-right: 0.3pt dashed #999; } .meta .cahier { font-size: 5.5pt; line-height: 1.3; } }

/* ---------------------------------------------------------------------------
   Mode sombre (écran uniquement : l'impression reste claire).
   Les pages du magazine restent blanches pour juger les maquettes.
   --------------------------------------------------------------------------- */
@media screen {
  :root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #121212;
    --surface: #1b1b1b;
    --paper: #242424;
    --ink: #eeeeee;
    --muted: #a8a8a8;
    --faint: #6f6f6f;
    --line: #383838;
    --line-soft: #2c2c2c;
    --ui-20: rgba(238,238,238,.14);
    --accent-25: #2b1812;
  }
  [data-theme="dark"] .page .sheet, [data-theme="dark"] .sheet-lg, [data-theme="dark"] .r-page:not(.blank) { background: #fff; }
  [data-theme="dark"] .page .empty-title, [data-theme="dark"] .sheet-lg .empty { color: #7a7a7a; }
  [data-theme="dark"] .btn.primary { color: #121212; }
  [data-theme="dark"] .btn.primary:hover { background: #d4d4d4; }
  [data-theme="dark"] .topbar { background: rgba(18,18,18,.92); }
  [data-theme="dark"] .selection-bar { background: var(--paper); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 10px 40px rgba(0,0,0,.6); }
  [data-theme="dark"] .selection-bar select, [data-theme="dark"] .selection-bar .btn:not(.ghost) { background: var(--surface); border-color: var(--line); color: var(--ink); }
  [data-theme="dark"] .selection-bar .btn.ghost { color: var(--ink); }
  [data-theme="dark"] .badge.presence { color: #121212; }
  [data-theme="dark"] .badge.versions { background: rgba(27,27,27,.9); }
  [data-theme="dark"] .tag.warn, [data-theme="dark"] .banner { color: #e6b866; }
  [data-theme="dark"] .toast { box-shadow: 0 8px 24px rgba(0,0,0,.5); }
  [data-theme="dark"] dialog { box-shadow: 0 20px 60px rgba(0,0,0,.6); }
  [data-theme="dark"] dialog::backdrop { background: rgba(0,0,0,.6); }
  [data-theme="dark"] .menu { box-shadow: 0 8px 24px rgba(0,0,0,.5); }
  [data-theme="dark"] .spread-lg { box-shadow: 0 4px 30px rgba(0,0,0,.5); }
}

@media print {
  :root { --pw: 23mm; background: #fff; }
  body { background: #fff; font-size: 8pt; }
  .topbar, .selection-bar, .hint, .panel, dialog, .reader, .toasts, .menu, .menu-btn, .badge.presence, .meta .sel { display: none !important; }
  body[data-print="A3"] { --pw: 33mm; }
  #app { display: block !important; }
  .print-only { display: block; margin-bottom: 6mm; }
  #printHeader h1 { font-size: 16pt; }
  #printHeader p { margin: 1mm 0; color: #555; }
  .board { padding: 0; gap: 7mm 5mm; }
  .spread { break-inside: avoid; }
  .page:hover .sheet { transform: none; }
  .page .sheet { box-shadow: 0 0 0 0.3pt #999; }
  .page.selected .sheet { outline: 0; }
  .meta { margin-top: 1mm; font-size: 7pt; }
  .lane { height: 3.5mm; }
  .lane span { font-size: 6pt; top: 1mm; line-height: 1; }
  .badge { transform: scale(.8); }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
body:has(.selection-bar:not([hidden])) .toasts { bottom: 96px; }
