:root {
  --navy: #1f2a44; --navy-2: #2b3a5c; --green: #2e7d32; --ink: #1d2433; --muted: #667085; --line: #e3e7ee;
  --bg: #f4f6f9; --card: #fff; --input: #f3f7fd; --input-line: #c9d6ea; --focus: #2563eb; --danger: #b42318;
  --warn-bg: #fff4e5; --ok-bg: #e7f5ea; --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 15px; line-height: 1.45; }
a { color: var(--focus); }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; }
code { background: #eef1f6; padding: 1px 6px; border-radius: 4px; }
code.pw { font-size: 16px; font-weight: bold; background: #fff; border: 1px dashed var(--green); padding: 3px 10px; }
.ar { font-family: "Segoe UI", Tahoma, Arial, sans-serif; color: var(--muted); font-size: .88em; margin-left: 4px; direction: rtl; unicode-bidi: isolate; }
.en { color: var(--muted); font-size: .88em; margin-left: 4px; font-style: italic; }
.en::before { content: "("; } .en::after { content: ")"; }

/* structure */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: var(--navy); color: #dfe5f2; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; border-bottom: 1px solid rgba(255,255,255,.1); margin-bottom: 10px; }
.brand strong { display: block; color: #fff; font-size: 15px; } .brand small { color: #9fb0d0; font-size: 12px; }
.brand-mark { background: var(--green); color: #fff; font-weight: 800; font-size: 12px; letter-spacing: .5px; border-radius: 8px; padding: 9px 7px; }
.brand-mark.lg { font-size: 15px; padding: 12px 10px; }
.sidebar nav { flex: 1; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: #8394b8; margin: 16px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 8px; color: #dfe5f2; text-decoration: none; background: none; border: 0; font: inherit; font-size: 14px; cursor: pointer; text-align: left; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.13); color: #fff; font-weight: 600; }
.nav-item.new .ic { color: var(--c); background: #fff; border-radius: 50%; padding: 2px; }
.nav-item small { display: block; color: #8394b8; font-size: 12px; }
.nav-form { margin: 0; }
.me { border-top: 1px solid rgba(255,255,255,.1); padding-top: 10px; }
.me form { margin: 0; }
.main { padding: 28px 36px 60px; max-width: 1400px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 0; }

/* cartes et éléments */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card.narrow { max-width: 460px; } .card.narrow2 { max-width: 720px; }
.sticky { position: sticky; top: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid2.wide-left { grid-template-columns: 1.7fr 1fr; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.flash { background: var(--ok-bg); border: 1px solid #b7dfc0; color: #1e5a26; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.alert { background: #fdecea; border: 1px solid #f5c2bd; color: var(--danger); padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid #c8d0dd; background: #fff; color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #f2f5fa; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: #276b2b; }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost.danger { background: transparent; color: var(--danger); border-color: #f0c2bd; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; cursor: wait; }
.icon-btn { border: 0; background: none; color: var(--muted); font-size: 20px; cursor: pointer; padding: 0 6px; line-height: 1; }
.icon-btn:hover { color: var(--danger); }

.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; vertical-align: middle; }
.badge.ok { background: var(--ok-bg); color: #1e5a26; } .badge.ko { background: #fdecea; color: var(--danger); } .badge.draft { background: var(--warn-bg); color: #9a5b00; }
.tbadge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 6px; color: var(--c); background: color-mix(in srgb, var(--c) 12%, white); border: 1px solid color-mix(in srgb, var(--c) 30%, white); }

/* champs */
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.flabel { font-weight: 600; color: #344054; }
.field.req .flabel::after { content: " *"; color: var(--danger); }
.hint { color: var(--muted); font-size: 12px; }
input, select, textarea { font: inherit; font-size: 15px; padding: 8px 10px; border: 1px solid var(--input-line); border-radius: 7px; background: var(--input); color: var(--ink); width: 100%; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--focus) 35%, white); border-color: var(--focus); background: #fff; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--green); padding: 0; }
.is-missing { border-color: #f0a35e !important; background: #fff4e5 !important; }
.money { display: flex; align-items: center; gap: 6px; } .money span { color: var(--muted); font-weight: 600; }

/* éditeur de certificat */
.editor-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.editor-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 4px; } .crumbs a { color: var(--muted); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; }
.save-state { font-size: 13px; color: var(--muted); margin-right: 6px; } .save-state.ok { color: var(--green); } .save-state.err { color: var(--danger); }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 18px; align-items: start; }
.sec-title { display: flex; align-items: center; gap: 10px; font-size: 15px; text-transform: uppercase; letter-spacing: .3px; color: var(--navy); border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 14px; }
.sec-title .ar, .sec-title .en { text-transform: none; }
.num { background: var(--navy); color: #fff; border-radius: 50%; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; flex: none; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.field.full { grid-column: 1 / -1; }
.card.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; min-width: 640px; }
table.grid th { font-size: 12px; text-align: left; color: #344054; padding: 6px; border-bottom: 1px solid var(--line); vertical-align: bottom; }
table.grid th.req::after { content: " *"; color: var(--danger); }
table.grid td { padding: 4px; }
table.grid input { padding: 7px 8px; font-size: 14px; }
table.grid .x { width: 30px; }
.table-foot { display: flex; justify-content: space-between; align-items: flex-start; margin-top: 10px; gap: 12px; flex-wrap: wrap; }
.total { text-align: right; font-size: 14px; } .total strong { font-size: 18px; background: #fff8db; padding: 2px 10px; border-radius: 6px; }
.words { font-style: italic; color: #344054; margin-top: 4px; }
.checklist { display: flex; flex-direction: column; gap: 6px; }
.cl-row { display: grid; grid-template-columns: 1.3fr 1fr; gap: 10px; align-items: center; }
.cl-check { display: flex; gap: 10px; align-items: center; cursor: pointer; font-size: 14px; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 4px 12px; }
.pitem { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.pitem:hover { background: #f2f5fa; }
.pitem:has(input:checked) { background: var(--ok-bg); font-weight: 600; }
.statement { font-style: italic; margin: 6px 0; } .statement.ar { font-style: normal; text-align: right; }
.fees-total { text-align: right; margin-top: 12px; font-size: 15px; } .fees-total strong { font-size: 18px; background: #fff8db; padding: 2px 10px; border-radius: 6px; }
.checkpanel .missing { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 4px; }
.missing li { background: var(--warn-bg); color: #8a4b00; border-radius: 6px; padding: 6px 10px; font-size: 13px; cursor: pointer; }
.missing li.ok { background: var(--ok-bg); color: #1e5a26; cursor: default; font-weight: 600; }

/* listes et tableaux */
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); }
table.list td { padding: 9px 8px; border-bottom: 1px solid #eef1f5; vertical-align: top; }
table.list tr.clickable { cursor: pointer; } table.list tr.clickable:hover td { background: #f7f9fc; }
table.list td.mono { white-space: nowrap; }
table.list td.clip { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.list .empty { text-align: center; color: var(--muted); padding: 24px; }
table.list form.row select { width: auto; padding: 4px 6px; font-size: 13px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input[name=q] { flex: 1; min-width: 220px; }
.filters select, .filters input[type=date] { width: auto; }
.filters label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.filters.inline { margin-bottom: 10px; }
.pager { display: flex; justify-content: center; gap: 12px; align-items: center; margin-top: 14px; }
dl.kv { display: grid; grid-template-columns: 170px 1fr; gap: 8px 12px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; font-weight: 600; }
.danger-zone { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.danger-zone summary { cursor: pointer; color: var(--danger); font-weight: 600; margin-bottom: 10px; }
.lists-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.lists-grid textarea { font-family: ui-monospace, Consolas, monospace; font-size: 13px; margin-bottom: 10px; }

/* tableau de bord */
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 18px; }
.quick form { margin: 0; }
.quick-card { width: 100%; text-align: left; background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--c); border-radius: var(--radius); padding: 16px 18px; cursor: pointer; font: inherit; display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; }
.quick-card:hover { box-shadow: 0 4px 14px rgba(16,24,40,.08); }
.quick-card .ic { grid-row: span 2; color: var(--c); }
.quick-card strong { font-size: 16px; } .quick-card small { color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.stat small { color: var(--muted); display: block; } .stat strong { font-size: 28px; }

/* authentification et vérification */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: linear-gradient(160deg, #1f2a44 0%, #2b3a5c 55%, #2e7d32 140%); }
.auth-card { background: #fff; border-radius: 14px; padding: 28px; width: 100%; max-width: 440px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.auth-brand strong { display: block; font-size: 17px; } .auth-brand small { color: var(--muted); }
.auth-card h1 { font-size: 21px; margin-bottom: 14px; }
.verify .verdict { border-radius: 10px; padding: 14px 16px; font-size: 20px; font-weight: 800; margin-bottom: 16px; }
.verify .verdict small { display: block; font-size: 13px; font-weight: 500; margin-top: 4px; }
.verdict.good { background: var(--ok-bg); color: #1e5a26; } .verdict.bad { background: #fdecea; color: var(--danger); }
.verify dl.kv { grid-template-columns: 150px 1fr; margin-bottom: 14px; }

/* téléphone et tablette */
@media (max-width: 1100px) {
  .editor { grid-template-columns: 1fr; }
  .checkpanel { order: -1; } .sticky { position: static; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 4px; } .nav-label { width: 100%; margin: 8px 6px 2px; }
  .nav-item { width: auto; } .nav-form { display: contents; }
  .main { padding: 18px 16px 48px; }
  .grid2, .grid2.wide-left, .card.pair, .fields, .cl-row { grid-template-columns: 1fr; }
  dl.kv { grid-template-columns: 1fr; } dl.kv dd { margin-bottom: 6px; }
}

/* produits multi-catégories */
.p-tools { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.p-summary { display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; align-items: center; }
.chip { display: inline-flex; flex-direction: column; align-items: flex-start; border: 1px solid #b7dfc0; background: var(--ok-bg); color: #1e5a26; border-radius: 8px; padding: 3px 10px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.chip small { font-size: 10.5px; font-weight: 500; color: #4b7a52; }
.chip:hover { background: #fdecea; border-color: #f5c2bd; color: var(--danger); }
details.pcat { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
details.pcat summary { cursor: pointer; padding: 10px 14px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; list-style: none; }
details.pcat summary::before { content: "▸"; margin-right: 8px; color: var(--muted); }
details.pcat[open] summary::before { content: "▾"; }
details.pcat summary .pcat-name { flex: 1; }
.pcount { font-size: 12px; background: var(--green); color: #fff; border-radius: 99px; padding: 1px 9px; }
.pcount:empty { display: none; }
details.pcat .pgrid { padding: 0 12px 8px; }
.p-add { display: flex; gap: 8px; padding: 0 14px 12px; max-width: 480px; }
.p-add input { padding: 6px 9px; font-size: 14px; }

.card.intro { background: #f7f9fc; font-style: italic; } .card.intro p { margin: 0 0 4px; }
h2.fam { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 6px 0 10px; }

/* logo MAEPE-RH */
.brand-logo { background: #fff; border-radius: 50%; padding: 3px; flex: none; object-fit: contain; }
.auth-logo { text-align: center; margin-bottom: 6px; }
.auth-logo img { height: auto; }
.auth-brand.center { justify-content: center; text-align: center; margin-bottom: 18px; }
