/* Factura — feuille de style unique, sans dépendance externe. */
:root {
  --ink: #16202e;
  --ink-soft: #4a5566;
  --ink-faint: #7b8494;
  --line: #e2e5ea;
  --line-strong: #cdd2da;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --brand: #1d3a5f;
  --brand-ink: #ffffff;
  --accent: #0f6e6a;
  --accent-soft: #e3f1f0;
  --ok: #1f7a46;
  --ok-soft: #e4f3ea;
  --warn: #9a6200;
  --warn-soft: #fbf1dc;
  --bad: #b3261e;
  --bad-soft: #fbe7e5;
  --info-soft: #e8eef7;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(22, 32, 46, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
p { margin: 0 0 12px; }
small, .muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
code, .mono { font-family: var(--mono); font-size: 13px; }

/* --- Structure --------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--brand); color: var(--brand-ink); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 18px; padding: 4px 10px 18px; letter-spacing: -.01em; }
.brand span { display: block; font-weight: 400; font-size: 12px; opacity: .7; }
.nav a { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.82); padding: 8px 10px; border-radius: 6px; font-size: 14px; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .55; padding: 14px 10px 4px; }
.sidebar-foot { margin-top: auto; font-size: 13px; padding: 10px; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-foot .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .role { opacity: .65; font-size: 12px; }
.sidebar-foot form { margin-top: 8px; }
.sidebar-foot button { background: none; border: 0; color: rgba(255,255,255,.8); padding: 0; cursor: pointer; font: inherit; }
.sidebar-foot button:hover { color: #fff; text-decoration: underline; }

.main { padding: 28px 32px 48px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 0; color: var(--ink-soft); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.topbar { display: none; }

/* --- Cartes et grilles ----------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card > h2:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.admin-entry p { margin: 6px 0 0; }
.admin-entry code { word-break: break-all; user-select: all; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .n { font-size: 26px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--ink-soft); font-size: 13px; }
.stat.attention { border-color: #e7c97d; background: var(--warn-soft); }

/* --- Tableaux --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--ink-soft); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #fafbfc; }
.empty { padding: 28px 10px; text-align: center; color: var(--ink-soft); }

/* --- Pastilles de statut ---------------------------------------------------------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--info-soft); color: var(--brand); }
.badge.received { background: var(--info-soft); color: var(--brand); }
.badge.processing { background: #eef0f3; color: var(--ink-soft); }
.badge.to_check, .badge.quarantine { background: var(--warn-soft); color: var(--warn); }
.badge.ready { background: var(--accent-soft); color: var(--accent); }
.badge.validated, .badge.exported { background: var(--ok-soft); color: var(--ok); }
.badge.unreadable, .badge.off { background: var(--bad-soft); color: var(--bad); }
.badge.neutral { background: #eef0f3; color: var(--ink-soft); }

/* --- Formulaires ------------------------------------------------------------- */
.form { display: grid; gap: 14px; max-width: 640px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.field .help { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.field .errors { color: var(--bad); font-size: 13px; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 6px; padding: 8px 10px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15, 110, 106, .25); border-color: var(--accent); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); vertical-align: -3px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400 !important; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 160px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-size: 14px; font-weight: 600; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--line-strong); background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #0b5c58; }
.btn.danger { color: var(--bad); border-color: #e9b8b3; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 0; font-weight: 400; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.inline-form { display: inline; }

/* --- Messages --------------------------------------------------------------------- */
.messages { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 8px; }
.messages li { padding: 10px 14px; border-radius: 6px; border: 1px solid; font-size: 14px; }
.messages .success { background: var(--ok-soft); border-color: #b9dfc8; color: #17532f; }
.messages .error { background: var(--bad-soft); border-color: #efc1bc; color: #8a1d16; }
.messages .warning { background: var(--warn-soft); border-color: #ecd59f; color: #6e4700; }
.messages .info { background: var(--info-soft); border-color: #c9d6ea; color: var(--brand); }

/* --- Zone de dépôt ------------------------------------------------------------------ */
.dropzone { border: 2px dashed var(--line-strong); border-radius: var(--radius); background: #fafbfc; padding: 28px 20px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .big { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.dropzone input[type=file] { display: none; }
.file-list { list-style: none; margin: 12px 0 0; padding: 0; text-align: left; font-size: 13px; display: grid; gap: 4px; }
.file-list li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 10px; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.file-list .size { color: var(--ink-faint); font-variant-numeric: tabular-nums; }

/* --- Pages de connexion -------------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-box { width: 100%; max-width: 400px; }
.auth-brand { text-align: center; margin-bottom: 18px; font-weight: 700; font-size: 22px; color: var(--brand); }
.auth-brand span { display: block; font-size: 13px; font-weight: 400; color: var(--ink-soft); }
.auth .card { padding: 24px; }
.auth .form { max-width: none; }
.lang-switch { display: flex; justify-content: center; gap: 4px; margin-top: 16px; flex-wrap: wrap; }
.lang-switch button { background: none; border: 0; font: inherit; font-size: 13px; color: var(--ink-soft); cursor: pointer; padding: 2px 6px; border-radius: 4px; }
.lang-switch button.current { color: var(--ink); font-weight: 600; background: #eceef1; }
.qr { display: flex; justify-content: center; margin: 8px 0 12px; }
.qr svg { width: 200px; height: 200px; }
.secret { font-family: var(--mono); font-size: 13px; background: #f3f4f6; padding: 6px 8px; border-radius: 4px; word-break: break-all; display: block; text-align: center; }

/* --- Divers ------------------------------------------------------------------------- */
dl.props { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; font-size: 14px; }
dl.props dt { color: var(--ink-soft); }
dl.props dd { margin: 0; }
.pagination { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; color: var(--ink-soft); border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 14px; }
.tabs a.active { color: var(--ink); border-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs .count { color: var(--ink-faint); font-weight: 400; }
pre.log { background: #10161f; color: #d5dde8; font: 12px/1.5 var(--mono); padding: 14px; border-radius: 6px; max-height: 380px; overflow: auto; white-space: pre-wrap; margin: 0; }
.preview { width: 100%; height: 72vh; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.preview-img { max-width: 100%; border: 1px solid var(--line); border-radius: 6px; }
.callout { padding: 12px 14px; border-radius: 6px; background: var(--info-soft); color: var(--brand); font-size: 14px; margin-bottom: 14px; }
.callout.warn { background: var(--warn-soft); color: #6e4700; }
.version-big { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* --- Téléphone ----------------------------------------------------------------------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; position: fixed; inset: 0; z-index: 20; height: auto; overflow-y: auto; }
  .sidebar.open { display: flex; }
  .topbar { display: flex; align-items: center; justify-content: space-between; background: var(--brand); color: #fff; padding: 10px 16px; position: sticky; top: 0; z-index: 10; }
  .topbar button { background: none; border: 1px solid rgba(255,255,255,.4); color: #fff; border-radius: 6px; padding: 4px 10px; font: inherit; }
  .main { padding: 18px 16px 40px; }
  .grid-2, .grid-3, .form-row { grid-template-columns: 1fr; }
  .hide-mobile { display: none; }
  .filters input, .filters select { min-width: 0; flex: 1 1 140px; }
}

/* Liens légaux */
.sidebar-foot .legal-links { margin-top: 8px; font-size: 11.5px; line-height: 1.6; }
.sidebar-foot .legal-links a { color: rgba(255,255,255,.65); }
.sidebar-foot .legal-links a:hover { color: #fff; }
.auth-legal { text-align: center; font-size: 12.5px; color: var(--ink-faint); margin-top: 14px; }
.auth-legal a { color: var(--ink-soft); }
.legal-missing { border-left: 4px solid var(--warn); background: var(--warn-soft); }

/* --- Historique des mises à jour ------------------------------------------- */
.op-cell { min-width: 240px; }
.timeline { max-width: 760px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line-strong); }
.timeline > li { position: relative; padding: 0 0 22px 16px; }
.timeline > li:last-child { padding-bottom: 0; }
.timeline > li::before { content: ""; position: absolute; left: -26px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--line-strong); }
.timeline > li.is-current::before { background: var(--accent); border-color: var(--accent); }
.timeline > li.is-pending .tl-version, .timeline > li.is-pending .tl-title { color: var(--ink-soft); }
.tl-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.tl-version { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.tl-title { font-weight: 600; }
.tl-meta { font-size: 13px; color: var(--ink-soft); margin: 4px 0 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tl-changes { margin: 0; padding-left: 18px; font-size: 14px; color: var(--ink); }
.tl-changes li { margin-bottom: 3px; }
