/* Fiducio 0.8.0 — feuille commune (site, application, portail, Super console). © Leologic Sàrl.
   Un seul conteneur sur grand écran : min(100% − 2 × gouttière, 1680px), bords alignés (barre du haut, contenu, pied de page). */
:root {
  --gutter: clamp(16px, 2.5vw, 56px);
  --container: 1680px;
  --primary: #1e4fd7; --primary-dark: #163eb0; --accent: #14b8a6; --danger: #b91c1c; --warn: #b45309; --ok: #0e7a56;
  --bg: #f4f6fb; --card: #ffffff; --text: #0f172a; --muted: #5b6475; --line: #e3e8ef; --soft: #f7f9fc; --hover: #eef3ff;
  --radius: 14px; --shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.05);
  --sort-h-active: var(--primary);
  color-scheme: light;
}
html[data-theme="dark"] {
  --primary: #5b8cff; --primary-dark: #7aa2ff; --accent: #2dd4bf; --danger: #f87171; --warn: #fbbf24; --ok: #34d399;
  --bg: #0b1020; --card: #121a2b; --text: #e6e9f0; --muted: #a7b0c0; --line: rgba(255,255,255,.12); --soft: #172036; --hover: rgba(255,255,255,.06);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
main { flex: 1 0 auto; }
a { color: var(--primary); }
img, svg { max-width: 100%; }
h1 { font-size: clamp(1.35rem, 2.2vw, 1.75rem); letter-spacing: -.02em; margin: 0 0 .4rem; font-weight: 750; }
h2 { font-size: 1.08rem; margin: 0 0 .75rem; font-weight: 700; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
p { margin: 0 0 .75rem; }
code { font-size: .88em; background: var(--soft); padding: 1px 5px; border-radius: 6px; overflow-wrap: anywhere; }
.wrap { width: min(100% - 2 * var(--gutter), var(--container)); margin-inline: auto; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; } .skip:focus { left: 8px; top: 8px; z-index: 999; background: var(--card); padding: 8px 12px; border-radius: 8px; }

/* Barre du haut (application, portail, pages publiques) */
.topbar { position: sticky; top: 0; z-index: 60; background: color-mix(in srgb, var(--card) 92%, transparent); border-bottom: 1px solid var(--line); backdrop-filter: saturate(1.4) blur(8px); }
.topbar-inner { display: flex; align-items: center; gap: 12px; min-height: 60px; }
.brand { display: inline-flex; align-items: center; flex: 0 0 auto; }
.brand img { height: 30px; width: auto; display: block; }
.brand .logo-dark { display: none; }
html[data-theme="dark"] .brand .logo-light { display: none; } html[data-theme="dark"] .brand .logo-dark { display: block; }
.mainnav { display: flex; align-items: center; gap: 2px; flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 600; font-size: .93rem; white-space: nowrap; }
.mainnav a:hover { background: var(--hover); }
.mainnav a[aria-current="page"] { background: var(--hover); color: var(--primary); }
.tools { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; margin-left: auto; }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 800; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font-size: .78rem; font-weight: 700; white-space: nowrap; }
.chip-secure { color: var(--ok); }
.chip svg { width: 14px; height: 14px; flex: 0 0 14px; }
.icon-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); text-decoration: none; }
.icon-btn:hover { background: var(--hover); }
.icon-btn .count { position: absolute; top: -6px; right: -6px; }
.leo-link { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); }
.leo-link:hover { background: var(--hover); }
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.lang-switch a { display: inline-flex; align-items: center; min-height: 34px; padding: 0 9px; font-size: .74rem; font-weight: 800; color: var(--text); text-decoration: none; }
.lang-switch a[aria-current="true"] { background: var(--primary); color: #fff; }
@media (max-width: 860px) {
  .topbar-inner { flex-wrap: wrap; padding-block: 6px; }
  .mainnav { order: 3; flex-basis: 100%; }
  .chip-secure span { display: none; }
}

/* Contenu */
.page { padding-block: 24px 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(16px, 2vw, 22px); margin-bottom: 16px; min-width: 0; }
.card > :last-child { margin-bottom: 0; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); align-items: start; }
.grid > .card { margin-bottom: 0; }
.grid + .card, .grid + .grid { margin-top: 16px; }
.kpis { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); text-decoration: none; color: var(--text); }
.kpi strong { display: block; font-size: 1.9rem; line-height: 1.1; letter-spacing: -.03em; }
.kpi span { color: var(--muted); font-size: .9rem; }
.kpi.warn strong { color: var(--warn); } .kpi.bad strong { color: var(--danger); } .kpi.good strong { color: var(--ok); }
.cols-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
@media (max-width: 960px) { .cols-2 { grid-template-columns: 1fr; } }

/* Formulaires */
label { display: block; font-size: .84rem; font-weight: 650; margin-bottom: 5px; min-width: 0; overflow-x: clip; overflow-clip-margin: 4px; }
input, select, textarea { width: 100%; max-width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: var(--card); color: var(--text); min-height: 42px; }
textarea { min-height: 96px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; min-height: 0; padding: 0; accent-color: var(--primary); flex: 0 0 auto; vertical-align: middle; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.field { margin-bottom: 14px; min-width: 0; }
.field small { display: block; color: var(--muted); margin-top: 4px; font-size: .8rem; }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; font-size: .92rem; margin: 10px 0; }
.form-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-row > .field { flex: 1 1 200px; margin-bottom: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.btn, button.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 16px; border-radius: 10px; border: 1px solid transparent; background: var(--primary); color: #fff; font: inherit; font-weight: 700; font-size: .93rem; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--primary-dark); }
html[data-theme="dark"] .btn { color: #0b1020; }
.btn-outline, button.btn-outline { background: var(--card); color: var(--text); border-color: var(--line); }
.btn-outline:hover { background: var(--hover); }
.btn-danger { background: var(--danger); } .btn-danger:hover { background: #991b1b; }
.btn-sm { min-height: 34px; padding: 5px 11px; font-size: .84rem; }
.btn-block { width: 100%; }
.linklike { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; text-decoration: underline; }
form.inline { display: inline; }

/* Messages */
.flash { padding: 12px 14px; border-radius: 12px; margin: 0 0 14px; border: 1px solid var(--line); background: var(--card); }
.flash-ok { border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: color-mix(in srgb, var(--ok) 9%, var(--card)); }
.flash-error { border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: color-mix(in srgb, var(--danger) 9%, var(--card)); }
.flash-warn { border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 10%, var(--card)); }
.banner { padding: 10px 0; font-weight: 650; font-size: .93rem; }
.banner .wrap { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.banner-danger { background: var(--danger); color: #fff; } .banner-danger a { color: #fff; }
.banner-info { background: #0b3d91; color: #fff; } .banner-info a { color: #fff; }
.banner-warn { background: #fef3c7; color: #78350f; } .banner-warn a { color: #78350f; }

/* Tableaux */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { background: var(--soft); font-size: .78rem; font-weight: 750; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
.table tbody tr:hover { background: var(--hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .sel { width: 44px; }
.table-tools { display: flex; gap: 10px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
.table-tools form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.table-tools input[type="search"] { max-width: 320px; }
.table-tools select { width: auto; }
.bulk { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.bulk select { width: auto; }
.empty { color: var(--muted); padding: 18px 12px; }
@media (max-width: 720px) {
  .table.stack thead { display: none; }
  .table.stack tr { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .table.stack td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 0; text-align: right; }
  .table.stack td::before { content: attr(data-label); font-weight: 700; color: var(--muted); text-align: left; }
  .table.stack td.sel::before { content: none; }
}
.pager { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.pager a, .pager span { display: inline-flex; align-items: center; min-height: 36px; padding: 4px 11px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); text-decoration: none; color: var(--text); font-size: .9rem; }
.pager .is-on { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager .is-off { color: var(--muted); opacity: .6; } .pager .gap { border: 0; background: none; }
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 750; white-space: nowrap; }
.badge-missing, .badge-warn { background: #fff4e5; color: #9a3412; } .badge-received, .badge-ok { background: #e8f8f2; color: #0e6b4b; }
.badge-off { background: var(--soft); color: var(--muted); } .badge-bad { background: #fee2e2; color: #991b1b; } .badge-info { background: #e0ecff; color: #1e3a8a; }
html[data-theme="dark"] .badge-missing, html[data-theme="dark"] .badge-warn { background: rgba(251,191,36,.18); color: #fde68a; }
html[data-theme="dark"] .badge-received, html[data-theme="dark"] .badge-ok { background: rgba(52,211,153,.16); color: #a7f3d0; }
html[data-theme="dark"] .badge-bad { background: rgba(248,113,113,.18); color: #fecaca; } html[data-theme="dark"] .badge-info { background: rgba(91,140,255,.2); color: #c7d7ff; }
.progress { display: inline-block; width: 90px; height: 7px; border-radius: 99px; background: var(--line); overflow: hidden; vertical-align: middle; margin-right: 6px; }
.progress i { display: block; height: 100%; background: var(--accent); }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.list-plain { list-style: none; margin: 0; padding: 0; } .list-plain li { padding: 10px 0; border-bottom: 1px solid var(--line); } .list-plain li:last-child { border-bottom: 0; }

/* Dépôt de pièces (portail) */
.dropzone { border: 2px dashed #94a3b8; border-radius: 14px; padding: 18px 14px; text-align: center; background: var(--soft); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone.dragover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--card)); }
.dropzone.uploading { border-color: var(--primary); } .dropzone.success { border-color: var(--ok); } .dropzone.error { border-color: var(--danger); }
.dropzone strong { display: block; }
.dz-row { min-width: 160px; padding: 10px; }
progress { width: 100%; height: 6px; }

/* Aide contextuelle */
details.help { border: 1px solid var(--line); border-radius: 12px; background: var(--card); margin-bottom: 16px; }
details.help summary { cursor: pointer; padding: 10px 14px; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 8px; }
details.help summary::-webkit-details-marker { display: none; }
details.help[open] summary { border-bottom: 1px solid var(--line); }
details.help .help-body { padding: 12px 14px; color: var(--muted); }
.help-icon { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; align-items: center; justify-content: center; background: var(--primary); color: #fff; font-size: .8rem; font-weight: 800; }

/* Pied de page : éléments groupés côte à côte */
.footer { border-top: 1px solid var(--line); padding-block: 18px 26px; color: var(--muted); font-size: .85rem; flex-shrink: 0; }
.footer-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.footer-row a { color: var(--muted); text-decoration: none; } .footer-row a:hover { color: var(--text); text-decoration: underline; }
.footer-row .sep { color: var(--muted); }
.pw-row { display: flex; gap: 8px; align-items: stretch; } .pw-row input { flex: 1 1 auto; min-width: 0; } .pw-row .btn { flex: 0 0 auto; }
.log-purge form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-block: 10px; } .log-purge form small { flex-basis: 100%; }

/* Pages d'authentification */
.auth { display: grid; place-items: start center; padding-block: clamp(24px, 6vh, 64px); }
.auth .card { width: min(100%, 440px); }
.auth .card.wide { width: min(100%, 620px); }
.auth-logo { display: block; margin: 0 auto 12px; height: 46px; width: auto; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .82rem; margin: 14px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.secret-box { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.05rem; background: var(--soft); border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; word-break: break-all; }
.legal { max-width: 900px; } .legal article p { line-height: 1.65; } .legal h2 { margin-top: 1.4rem; }
.cga-box { max-height: 360px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--soft); font-size: .9rem; }

/* Console : contenu sous la navigation standard (console-nav) */
.console-body .page { padding-top: 20px; }
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.st-ok { background: #16a34a; } .st-info { background: #3b82f6; } .st-warning { background: #f59e0b; } .st-error { background: #dc2626; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; border-bottom: 1px solid var(--line); padding-top: 8px; }
.bars span { flex: 1 1 0; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .85; }
.bars-legend { display: flex; justify-content: space-between; color: var(--muted); font-size: .75rem; margin-top: 4px; }
.copy-list { white-space: pre; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }

/* Super Leo */
.leo-picto { display: block; }

@media print { .topbar, .footer, .cn-top, .actions, .no-print { display: none !important; } body { background: #fff; } .card { box-shadow: none; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
