:root {
  --bg: #f6f6f3;
  --panel: #ffffff;
  --ink: #1d1f22;
  --muted: #5d636b;
  --line: #d9dbd6;
  --accent: #1f5fae;
  --ok: #1d7a46;
  --ok-bg: #e3f3e9;
  --warn: #8a5a00;
  --warn-bg: #fdf1d8;
  --err: #b3261e;
  --err-bg: #fbe6e4;
  --info-bg: #e8eef8;
  --anchor: #5b3fa6;
  --editorial: #2a6f97;
  --advertisement: #b5651d;
  --filler: #6b7280;
  --stale: #7a6a00;
  font-size: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.4;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button, select, input { font: inherit; }
button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.danger { color: var(--err); }
button:disabled { opacity: .45; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=text], input[type=number], select { border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px; background: #fff; }
input.mmss { width: 5.2em; font-variant-numeric: tabular-nums; }
input.num { width: 7em; }
header.top {
  position: sticky; top: 0; z-index: 5;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 8px 16px;
}
header.top h1 { font-size: 16px; margin: 0 12px 0 0; display: inline; }
header.top .proj { color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.notice { margin: 8px 16px 0; padding: 8px 12px; border-radius: 6px; background: var(--info-bg); display: flex; gap: 12px; align-items: flex-start; }
.notice.error { background: var(--err-bg); }
.notice.ok { background: var(--ok-bg); }
.notice.warning { background: var(--warn-bg); }
.notice .close { margin-left: auto; }
.notice pre { white-space: pre-wrap; margin: 4px 0 0; font-size: 12px; }
main {
  display: grid;
  grid-template-columns: minmax(420px, 1.1fr) minmax(480px, 1.35fr) minmax(340px, 0.95fr);
  gap: 12px; padding: 12px 16px 40px;
  align-items: start;
}
@media (max-width: 1350px) { main { grid-template-columns: 1fr 1fr; } main > .zone-diag { grid-column: 1 / -1; } }
@media (max-width: 900px) { main { grid-template-columns: 1fr; } }
section.zone { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-width: 0; }
section.zone > h2 { font-size: 15px; margin: 0 0 8px; display: flex; gap: 8px; align-items: center; }
h3 { font-size: 13px; margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tabs button[aria-selected=true] { background: var(--ink); color: #fff; border-color: var(--ink); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 4px 5px; border-bottom: 1px solid #eceee9; vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 12px; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.row-actions button { padding: 2px 7px; font-size: 12px; }
tr.unavailable td { color: #9aa0a6; }
tr.hl td { background: #fff7cc; }
.kind { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 10px; color: #fff; white-space: nowrap; }
.kind.anchor { background: var(--anchor); }
.kind.editorial { background: var(--editorial); }
.kind.advertisement { background: var(--advertisement); }
.kind.filler { background: var(--filler); }
.tag { display: inline-block; background: #eef0eb; border-radius: 4px; padding: 0 5px; margin: 0 2px 2px 0; font-size: 12px; }
.tag.unknown { background: var(--warn-bg); color: var(--warn); }
.tag.empty { background: transparent; color: var(--muted); font-style: italic; }
.status { display: inline-block; font-weight: 700; font-size: 12px; padding: 2px 8px; border-radius: 4px; letter-spacing: .02em; }
.status.VALID { background: var(--ok-bg); color: var(--ok); }
.status.VALID_WITH_FILLER { background: #e6f0d6; color: #4b6b12; }
.status.INVALID, .status.INFEASIBLE, .status.INVALID_INPUT, .status.REJECTED_BY_VERIFIER { background: var(--err-bg); color: var(--err); }
.status.INCOMPLETE_DATA, .status.TIMEOUT { background: var(--warn-bg); color: var(--warn); }
.status.CANCELLED, .status.RUNNING, .status.NO_OTHER_SOLUTION { background: #eceff3; color: #3c4043; }
.stale { display: inline-block; font-size: 12px; font-weight: 600; color: var(--stale); background: #fff8c4; border: 1px dashed #c9b400; padding: 1px 6px; border-radius: 4px; }
.fresh { font-size: 12px; color: var(--ok); }
.badge { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 3px; border: 1px solid var(--line); white-space: nowrap; }
.badge.fixed { border-color: var(--anchor); color: var(--anchor); }
.badge.lock { border-color: var(--accent); color: var(--accent); }
.badge.missing { border-color: var(--err); color: var(--err); }

/* Frise chronologique */
.timeline { position: relative; margin: 6px 0 4px; }
.ruler { position: relative; height: 16px; font-size: 10px; color: var(--muted); }
.ruler span { position: absolute; transform: translateX(-50%); }
.ruler span:first-child { transform: none; }
.ruler span:last-child { transform: translateX(-100%); }
.lanes { position: relative; background: repeating-linear-gradient(45deg, #fff, #fff 5px, #f1e3e3 5px, #f1e3e3 10px); border: 1px solid var(--line); border-radius: 4px; }
.block {
  position: absolute; top: 0; height: 100%;
  border-right: 1px solid #fff; color: #fff; font-size: 10px; line-height: 1.15;
  padding: 2px 3px; overflow: hidden; white-space: nowrap; cursor: default;
}
.block.anchor { background: var(--anchor); }
.block.editorial { background: var(--editorial); }
.block.advertisement { background: var(--advertisement); }
.block.filler { background: var(--filler); }
.block.err { box-shadow: inset 0 0 0 2px var(--err); }
.block.hl { box-shadow: inset 0 0 0 3px #ffd60a; }
.block .k { opacity: .85; display: block; }
.block.lock::after { content: "🔒"; position: absolute; right: 2px; bottom: 1px; font-size: 9px; }
.ghost { position: absolute; top: 0; height: 100%; border: 2px dashed var(--err); background: rgba(179,38,30,.06); font-size: 10px; color: var(--err); padding: 1px 3px; overflow: hidden; white-space: nowrap; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.legend .hatch { display: inline-block; width: 14px; height: 10px; vertical-align: middle; background: repeating-linear-gradient(45deg, #fff, #fff 3px, #f1e3e3 3px, #f1e3e3 6px); border: 1px solid var(--line); }

.addform { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 8px 0; padding: 8px; background: #f7f8f5; border-radius: 6px; }
.diag-list { list-style: none; margin: 0; padding: 0; }
.diag-list li { border-left: 4px solid var(--line); padding: 5px 8px; margin: 0 0 6px; background: #fafbf9; border-radius: 0 4px 4px 0; font-size: 13px; }
.diag-list li.error { border-color: var(--err); }
.diag-list li.input { border-color: var(--err); background: var(--err-bg); }
.diag-list li.incomplete, .diag-list li.warning { border-color: #d39b00; }
.diag-list li.info { border-color: var(--accent); }
.diag-list li button.linklike { background: none; border: none; padding: 0; color: var(--accent); text-decoration: underline; font-size: 12px; }
.diag-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 13px; margin: 6px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
details { margin: 6px 0; }
details > summary { cursor: pointer; font-weight: 600; }
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 8px 0; padding: 6px 10px; }
legend { font-weight: 600; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: max-content 1fr; gap: 6px 10px; align-items: center; }
.form-grid label { color: var(--muted); }
.checks label { margin-right: 10px; white-space: nowrap; }
dialog { border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; max-width: 620px; width: 92vw; }
dialog::backdrop { background: rgba(0,0,0,.25); }
dialog h2 { margin-top: 0; font-size: 16px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.field-errors { color: var(--err); font-size: 12px; margin: 8px 0 0; padding-left: 18px; }
.running { display: inline-flex; gap: 6px; align-items: center; }
.spinner { width: 12px; height: 12px; border: 2px solid #bbb; border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.panel-sub { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 8px; }
.kbd { font-family: ui-monospace, Menlo, monospace; font-size: 11px; border: 1px solid var(--line); border-radius: 3px; padding: 0 3px; background: #fafafa; }

.zone-cat td .kind { margin-left: 4px; }
.zone-cat td { white-space: nowrap; }
.zone-cat td .small.muted { white-space: normal; max-width: 16em; }

/* P1 : déplacement à la souris */
.timeline.editable .lanes { touch-action: pan-y; }
.block.movable { cursor: grab; }
.block.movable:hover { filter: brightness(1.12); }
.block.dragging { cursor: grabbing; z-index: 5; opacity: .92; outline: 2px solid #1d1d1d; outline-offset: -1px; overflow: visible; }
.block.dragging.snapped { outline-color: #ffd60a; }
.drag-label { position: absolute; left: 0; top: -16px; background: #1d1d1d; color: #fff; font-size: 10px; padding: 0 4px; border-radius: 3px; white-space: nowrap; pointer-events: none; }
.drop-indicator { position: absolute; top: 0; height: 100%; border: 2px dashed #1d1d1d; background: rgba(255,214,10,.35); font-size: 10px; color: #1d1d1d; padding: 1px 3px; white-space: nowrap; overflow: hidden; pointer-events: none; z-index: 4; }
.drag-handle { cursor: grab; color: var(--muted); user-select: none; padding: 0 2px; }
.drag-handle:hover { color: inherit; }

/* P1 : comparaison de deux propositions */
.cmp-select { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 6px; align-items: center; margin: 4px 0 8px; }
.cmp-select select { width: 100%; min-width: 0; }
.cmp-select #cmp-swap { grid-column: 3; grid-row: 1 / span 2; }
.cmp-head { font-size: 12px; margin-top: 6px; }
.block.same { opacity: .45; }
.block.diff { box-shadow: inset 0 0 0 2px #ffd60a; }
tr.cmp-only-a td:first-child { border-left: 3px solid var(--err); }
tr.cmp-only-b td:first-child { border-left: 3px solid var(--ok); }
tr.cmp-moved td:first-child { border-left: 3px solid #ffd60a; }

.version { font-size: 11px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 3px; padding: 0 5px; margin-right: 8px; vertical-align: 2px; }
.version.mismatch { color: #fff; background: var(--err); border-color: var(--err); }

/* Conducteur imprimable */
#print-root { display: none; }
@media print {
  body.printing #app, body.printing #dialog, body.printing #announcer { display: none !important; }
  body.printing { background: #fff; }
  body.printing #print-root { display: block; font-size: 11pt; color: #000; }
  #print-root h1 { font-size: 16pt; margin: 0 0 4pt; }
  #print-root table { width: 100%; border-collapse: collapse; }
  #print-root th, #print-root td { border-bottom: 0.5pt solid #999; padding: 3pt 4pt; text-align: left; font-variant-numeric: tabular-nums; }
  #print-root tr { break-inside: avoid; }
  #print-root .print-fp, #print-root .print-note { font-size: 8pt; color: #444; }
  @page { margin: 14mm; }
}

/* ---------------------------------------------------------------- Journée 24 h (v0.6) */
.day-main { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr); gap: 12px; padding: 12px 16px; align-items: start; }
@media (max-width: 1100px) { .day-main { grid-template-columns: 1fr; } }
.day-main .side { display: grid; gap: 12px; min-width: 0; }
.day-page footer { padding: 8px 16px 16px; }
.day-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.day-tabs button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.hrow { display: grid; grid-template-columns: 34px minmax(0, 1fr) 128px; gap: 6px; align-items: center; padding: 1px 0; }
.hrow.changed { background: #fff8c4; border-radius: 4px; }
.hlab { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); text-align: right; }
.hstat { font-size: 12px; }
.hstat .status { padding: 0 5px; }
.ok-dot { color: var(--ok); font-weight: 700; }
.hbar { position: relative; height: 22px; background: #eef0eb; border-radius: 3px; overflow: hidden; }
.hbar.compact { height: 16px; margin-bottom: 4px; }
.hbar.ticks { background: transparent; height: 14px; overflow: visible; }
.hbar.ticks span { position: absolute; font-size: 11px; color: var(--muted); transform: translateX(-2px); }
.hbar .blk { position: absolute; top: 0; bottom: 0; border: 0; border-right: 1px solid #fff; border-radius: 0; padding: 0 2px; margin: 0; font-size: 10px; line-height: 22px; color: #fff; overflow: hidden; white-space: nowrap; text-align: left; cursor: pointer; }
.hbar.compact .blk { line-height: 16px; cursor: default; }
.hbar .blk:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; z-index: 2; }
.blk.k-anchor, .blk-l.k-anchor { background: var(--anchor); }
.blk.k-editorial, .blk-l.k-editorial { background: var(--editorial); }
.blk.k-advertisement, .blk-l.k-advertisement { background: var(--advertisement); }
.blk.k-filler, .blk-l.k-filler { background: var(--filler); }
.blk.new { box-shadow: inset 0 0 0 2px #ffd400; }
.blk-l { display: inline-block; color: #fff; padding: 0 6px; border-radius: 3px; font-size: 11px; }
.legend { margin: 0 0 6px; }
.kvt th { text-align: left; color: var(--muted); font-weight: 400; padding-right: 10px; vertical-align: top; white-space: nowrap; }
.chg { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 6px; }
.chg h3 { font-size: 13px; margin: 0 0 4px; }
ul.err { color: var(--err); }

/* ---------------------------------------------------------------- Catalogue : recherche et pages (v0.7) */
.cat-search { display: flex; gap: 8px; align-items: center; margin: 4px 0 6px; }
.cat-search input[type="search"] { flex: 1; min-width: 0; }
.pager { display: flex; gap: 6px; align-items: center; margin: 0 0 6px; }
.pager button { padding: 0 8px; }

/* v0.7 : langue, lien journée ↔ heure, règles dérivées */
.lang { font-size: 11px; font-weight: 700; padding: 1px 7px; margin-left: 8px; }
.hstat { display: flex; gap: 4px; align-items: center; }
.open-hour { margin-left: auto; padding: 0 6px; font-size: 12px; line-height: 18px; }
.notice.day-link { background: #e7f0ff; border: 1px solid #b7cdf5; }
.derived-rule { background: #fafafa; }
.derived-rule details p { word-break: break-word; }

/* v0.8 : utilisation à plusieurs */
.shared-bar { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 8px 16px 0; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: #f6f9ff; }
.shared-bar input { width: 12em; }
.lock-tag { background: #fde8c8; border-color: #f0b46a; white-space: nowrap; }
tr.asset-form td { background: #fafafa; }
.list-handle { cursor: grab; color: var(--muted); padding: 0 4px; user-select: none; }
tr.drop-before td { box-shadow: inset 0 3px 0 var(--accent, #2a62d6); }
tbody.drop-end tr:last-child td { box-shadow: inset 0 -3px 0 var(--accent, #2a62d6); }
tr.dragging { opacity: 0.4; }
