/* BDC Logicmax — feuille de style commune (recherche + articles) */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #1a2230;
  --muted: #5c6676;
  --line: #e0e5ec;
  --accent: #1b5fa8;
  --accent-ink: #ffffff;
  --accent-soft: #e7effa;
  --mark: #ffe27a;
  --mark-current: #ff9f43;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font); }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Bandeau --- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 650; font-size: 17px; white-space: nowrap; }
.brand-mark {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 15px;
}
.topbar-info { margin: 0 0 0 auto; color: var(--muted); font-size: 13px; }
.topsearch { margin-left: auto; flex: 0 1 380px; }
.topsearch input {
  width: 100%; padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
.topsearch input:focus { background: var(--surface); border-color: var(--accent); outline: none; }

/* --- Page de recherche --- */
.search-layout {
  display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 28px;
  max-width: 1240px; margin: 0 auto; padding: 24px;
}
.cats { position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 96px); overflow: auto; padding-right: 4px; }
.cats h2 { display: flex; justify-content: space-between; align-items: center; margin: 6px 0 10px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cats-close { display: none; border: 0; background: none; font-size: 18px; cursor: pointer; padding: 4px 8px; color: var(--ink); }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { display: none; padding-left: 14px; }
.tree li.is-open > ul { display: block; }
.tree li { display: grid; grid-template-columns: 20px minmax(0, 1fr); align-items: start; }
.tree li > ul { grid-column: 1 / -1; }
.tog, .tog-space { width: 20px; height: 30px; }
.tog { border: 0; background: none; cursor: pointer; padding: 0; color: var(--muted); }
.tog::before { content: "▸"; display: inline-block; transition: transform .15s; }
.is-open > .tog::before { transform: rotate(90deg); }
.cat {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 30px; padding: 4px 8px;
  border: 0; border-radius: 6px; background: none; cursor: pointer; text-align: left; line-height: 1.3;
}
.cat:hover { background: var(--accent-soft); }
.cat.is-active { background: var(--accent); color: var(--accent-ink); }
.cat.is-zero { color: #9aa3b0; }
.cat-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.n { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cat.is-active .n { color: inherit; opacity: .85; }

.searchbox { position: relative; }
.searchbox input {
  width: 100%; padding: 14px 44px 14px 16px; font-size: 17px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  box-shadow: 0 1px 2px rgba(20, 30, 50, .05);
}
.searchbox input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.hint {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  padding: 1px 7px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); font: 12px var(--font);
}
.searchbox input:focus + .hint { display: none; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin: 14px 0 8px; color: var(--muted); font-size: 14px; }
.count { margin: 0 auto 0 0; color: var(--ink); font-weight: 600; }
.check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.sort select { margin-left: 4px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.cats-toggle { display: none; }

.active-cat {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 10px;
  padding: 8px 12px; border-radius: 8px; background: var(--accent-soft); font-size: 14px;
}
.active-cat button { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; text-decoration: underline; }
.tips { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.tips code { padding: 0 4px; border-radius: 4px; background: var(--surface); border: 1px solid var(--line); }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.res {
  display: grid; gap: 3px; padding: 14px 18px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: inherit; text-decoration: none;
}
.res:hover, .res:focus-visible { border-color: var(--accent); box-shadow: 0 2px 10px rgba(27, 95, 168, .10); }
.res-cat { font-size: 12px; color: var(--muted); }
.res-title { font-size: 16.5px; font-weight: 620; color: var(--accent); }
.res-snip { font-size: 14px; color: #39424f; overflow-wrap: anywhere; }
.res-meta { font-size: 12px; color: var(--muted); }
.empty { padding: 28px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty button { margin: 10px 6px 0; padding: 6px 12px; border: 1px solid var(--accent); border-radius: 6px; background: var(--surface); color: var(--accent); cursor: pointer; }

/* --- Page d'article --- */
.article-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 28px;
  max-width: 1240px; margin: 0 auto; padding: 24px;
}
.article {
  min-width: 0; padding: 26px 34px 34px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.back { display: inline-block; margin-bottom: 10px; font-size: 14px; text-decoration: none; }
.crumbs { font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.article h1 { margin: 8px 0 6px; font-size: 26px; line-height: 1.25; overflow-wrap: anywhere; }
.meta { margin: 0 0 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.hl-bar {
  position: sticky; top: 62px; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 0 0 18px;
  padding: 8px 12px; border-radius: 8px; background: #fff6d6; border: 1px solid #f1dd94; font-size: 14px;
}
.hl-pos { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: auto; }
.hl-bar button { padding: 3px 10px; border: 1px solid #d9c27a; border-radius: 6px; background: var(--surface); cursor: pointer; }
mark.is-current { background: var(--mark-current); box-shadow: 0 0 0 2px var(--mark-current); }

.content { overflow-wrap: anywhere; }
.content img { max-width: 100%; height: auto; }
.content table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.content td, .content th { border: 1px solid #ccd3dc; padding: 4px 8px; vertical-align: top; }
.content pre { overflow-x: auto; padding: 10px; background: var(--bg); border-radius: 6px; }
.content iframe, .content video { max-width: 100%; }

.related { position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 96px); overflow: auto; }
.related h2 { display: flex; justify-content: space-between; gap: 8px; margin: 6px 0 10px; font-size: 13px; color: var(--muted); }
.related ul { list-style: none; margin: 0; padding: 0; }
.related a { display: block; padding: 6px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; font-size: 14px; line-height: 1.35; }
.related a:hover { background: var(--accent-soft); }
.related a.is-current { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* --- Petits écrans --- */
@media (max-width: 860px) {
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .topbar-info { display: none; }
  .topsearch { flex: 1 1 200px; }
  .search-layout, .article-layout { grid-template-columns: minmax(0, 1fr); padding: 16px; gap: 16px; }
  .cats { display: none; }
  .cats.is-shown {
    display: block; position: fixed; inset: 0; z-index: 30; max-height: none; align-self: stretch; justify-self: stretch;
    padding: 12px 16px 24px; background: var(--surface); overflow: auto;
  }
  .cats-close { display: block; }
  .cats-toggle {
    display: inline-block; padding: 5px 12px; border: 1px solid var(--line); border-radius: 6px;
    background: var(--surface); cursor: pointer;
  }
  .hint { display: none; }
  .article { padding: 18px 16px 24px; }
  .article h1 { font-size: 22px; }
  .hl-bar { top: 104px; }
  .related { position: static; max-height: none; }
}

@media print {
  .topbar, .related, .back, .hl-bar { display: none !important; }
  body { background: #fff; }
  .article-layout { display: block; padding: 0; }
  .article { border: 0; padding: 0; }
}
