/* Style volontairement sobre — à remplacer par la charte graphique Pixeo quand elle existera.
   Toutes les couleurs sont dans les variables ci-dessous. */
:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --text: #1f1f1d;
  --muted: #6b6b66;
  --line: #e3e3df;
  --accent: #2f5bea;
  --accent-soft: #eaf0fe;
  --danger: #b4362a;
  --green: #1d7a4c; --green-bg: #e5f3eb;
  --blue: #2856c7;  --blue-bg: #e8eefc;
  --red: #b4362a;   --red-bg: #fbe9e7;
  --amber: #8f5c00; --amber-bg: #fcf1d9;
  --gray: #55554f;  --gray-bg: #eeeeeb;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514; --panel: #1e1e1c; --text: #ebebe8; --muted: #9b9b95; --line: #32322e;
    --accent: #7d9cff; --accent-soft: #232b45; --danger: #ef8a7f;
    --green: #7fd1a5; --green-bg: #1b3326; --blue: #9db5ff; --blue-bg: #1f2a47;
    --red: #f19a90; --red-bg: #3d1f1b; --amber: #e9c06a; --amber-bg: #3a2f17;
    --gray: #c2c2bc; --gray-bg: #2c2c29;
  }
}

* { box-sizing: border-box; }
body { margin: 0; display: flex; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0; line-height: 1.25; }
h2 { font-size: 15px; margin: 28px 0 10px; }

/* Menu latéral */
.side { width: 220px; flex: none; position: sticky; top: 0; height: 100vh; overflow: auto;
  display: flex; flex-direction: column; gap: 12px; padding: 18px 12px;
  background: var(--panel); border-right: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; padding: 0 8px; letter-spacing: -.01em; }
nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
nav a { padding: 6px 8px; border-radius: 6px; color: var(--text); text-decoration: none; }
nav a:hover { background: var(--bg); }
nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 8px 4px; }

main { flex: 1; min-width: 0; max-width: 1240px; padding: 28px 36px 60px; }

/* Éléments communs */
.head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pre { white-space: pre-wrap; }
.empty { color: var(--muted); padding: 14px 16px; background: var(--panel); border: 1px dashed var(--line); border-radius: 10px; margin: 0; }
.flash { background: var(--green-bg); color: var(--green); padding: 9px 12px; border-radius: 8px; margin-bottom: 16px; }
.errors { background: var(--red-bg); color: var(--red); padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.welcome { background: var(--accent-soft); padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--gray-bg); color: var(--muted); font-size: 12px; text-align: center; font-weight: 500; }

.btn { display: inline-block; padding: 7px 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel);
  color: var(--text); text-decoration: none; font: inherit; line-height: 1.2; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.small { width: 100%; padding: 6px 9px; font-size: 12px; }
.btn.small-inline { padding: 4px 9px; font-size: 12px; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
button.link.danger { color: var(--danger); }

input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.search input { background: var(--bg); }

/* Listes */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input { max-width: 280px; }
.toolbar select { width: auto; }
.scroll { overflow-x: auto; }
table.list { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.list th, .list td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.list th { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.list th a { color: inherit; text-decoration: none; }
.list tbody tr:last-child td { border-bottom: 0; }
.list tbody tr:hover td { background: var(--bg); }
.list tfoot td { border-top: 1px solid var(--line); border-bottom: 0; }
.list td .pre { max-height: 4.5em; overflow: hidden; }
.num { text-align: right !important; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-link { font-weight: 600; color: var(--text); text-decoration: none; }
.row-link:hover { color: var(--accent); }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions form { display: inline; margin-left: 10px; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.gray { background: var(--gray-bg); color: var(--gray); }

/* Fiche */
.fields { display: grid; grid-template-columns: 190px 1fr; gap: 8px 18px; margin: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; }
.fields dt { color: var(--muted); }
.fields dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.sub-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.inline-add { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.inline-add .cell { flex: 1; min-width: 90px; }
.inline-add .cell.grow { flex: 4; }

/* Formulaires */
.form .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; padding: 20px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.form .grid.one { grid-template-columns: 1fr; }
.form.narrow { max-width: 560px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field.wide { grid-column: 1 / -1; }
.field small { display: block; color: var(--muted); margin-top: 3px; }
.form-actions { display: flex; gap: 8px; margin-top: 14px; }

/* Tableau de bord */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.card { display: block; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; color: var(--text); text-decoration: none; }
.card:hover { border-color: var(--muted); }
.card .k { font-size: 12px; color: var(--muted); }
.card .v { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.card .s { font-size: 12px; color: var(--muted); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.results { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.results li { padding: 9px 14px; border-bottom: 1px solid var(--line); }
.results li:last-child { border-bottom: 0; }

/* Documentation */
.docs { display: grid; grid-template-columns: 250px 1fr; gap: 24px; align-items: start; }
.tree { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow: auto; font-size: 13px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.tree form { margin-bottom: 10px; }
.tree ul { list-style: none; margin: 0; padding-left: 10px; }
.tree > ul { padding-left: 0; }
.tree summary { cursor: pointer; font-weight: 600; padding: 4px 2px; }
.tree a { display: block; padding: 3px 6px; border-radius: 5px; color: var(--text); text-decoration: none; }
.tree a:hover { background: var(--bg); }
.tree a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tree a.file::before { content: "↗ "; color: var(--muted); }
.tree a.add { color: var(--muted); font-size: 12px; }
.doc-main { min-width: 0; }
.doc-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.md { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 26px 34px; line-height: 1.65; overflow-wrap: anywhere; max-width: 900px; }
.md > :first-child { margin-top: 0; }
.md h1 { font-size: 24px; margin-bottom: 16px; }
.md h2 { font-size: 18px; margin-top: 30px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.md h3 { font-size: 15px; margin-top: 22px; }
.md code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: .92em; }
.md pre { background: var(--bg); padding: 12px 14px; border-radius: 8px; overflow: auto; }
.md pre code { padding: 0; background: none; }
.md table { border-collapse: collapse; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.md blockquote { margin: 0; padding: 4px 14px; border-left: 3px solid var(--accent); color: var(--muted); }
.md img { max-width: 100%; border-radius: 6px; }
.md input[type="checkbox"] { width: auto; }
.editor { width: 100%; min-height: 72vh; font: 13px/1.6 ui-monospace, Consolas, monospace; }

/* Connexion */
.login-body { align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.login .brand { padding: 0; font-size: 22px; }
.login p { margin: -10px 0 4px; }
.login .btn { width: 100%; padding: 9px; }

@media (max-width: 860px) {
  body { flex-direction: column; }
  .side { width: auto; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  main { padding: 20px 16px 40px; }
  .cols, .docs, .form .grid, .fields { grid-template-columns: 1fr; }
  .tree { position: static; max-height: none; }
  .md { padding: 18px 16px; }
  .inline-add { flex-wrap: wrap; }
}
