/* SFEC Certif — feuille de style. Base : Bootstrap 5, surchargée par les jetons ci-dessous. */
:root {
  --ink: #1C2B3A;
  --ink-soft: #4A5A6A;
  --paper: #F6F7F5;
  --surface: #FFFFFF;
  --rule: #D9E2EA;
  --seal: #0F6B52;
  --seal-tint: #E3F1EC;
  --amber: #A86412;
  --amber-tint: #FBF0DF;
  --red: #B42318;
  --red-tint: #FCE9E7;
  --violet: #5B3E96;
  --violet-tint: #EFEAF8;
  --radius: 6px;
  --bs-body-font-family: "Public Sans", system-ui, sans-serif;
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--paper);
  --bs-link-color: var(--seal);
  --bs-link-hover-color: #0A4E3C;
  --bs-border-color: var(--rule);
  --bs-border-radius: var(--radius);
}

body { font-size: .95rem; line-height: 1.5; min-height: 100vh; }
h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.01em; color: var(--ink); }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
.text-muted, .form-text { color: var(--ink-soft) !important; }
.num, .table td.num, .table th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
:focus-visible { outline: 3px solid #2F7FD1; outline-offset: 2px; }

/* Bande d'environnement : l'élément fort de l'interface */
.env-strip { display: flex; align-items: center; gap: .75rem; padding: .4rem 1.25rem; font-size: .85rem; font-weight: 600; color: #fff; }
.env-strip.sandbox {
  background: repeating-linear-gradient(135deg, var(--violet) 0 14px, #4E3483 14px 28px);
}
.env-strip.production { background: var(--ink); border-bottom: 4px solid var(--red); }
.env-strip.none { background: var(--ink-soft); }
.env-strip a { color: #fff; text-decoration: underline; }

/* Structure */
.app-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - 34px); }
.sidebar { background: var(--surface); border-right: 1px solid var(--rule); padding: 1.25rem 1rem; }
.sidebar .brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.05rem; color: var(--ink); text-decoration: none; margin-bottom: 1.5rem; }
.brand-mark { width: 30px; height: 30px; border: 2px solid var(--seal); border-radius: 50%; display: grid; place-items: center; color: var(--seal); font-size: .8rem; font-weight: 800; box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 3px var(--seal); }
.sidebar .nav-link { color: var(--ink-soft); padding: .45rem .6rem; border-radius: var(--radius); display: flex; gap: .6rem; align-items: center; }
.sidebar .nav-link:hover { background: var(--paper); color: var(--ink); }
.sidebar .nav-link.active { background: var(--seal-tint); color: var(--seal); font-weight: 600; }
.sidebar .nav-section { font-size: .8rem; color: var(--ink-soft); margin: 1.25rem .6rem .35rem; }
.main { padding: 1.75rem 2rem 3rem; max-width: 1280px; width: 100%; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-head p { margin: .25rem 0 0; color: var(--ink-soft); }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--rule); padding: .75rem 1rem; }
  .sidebar nav.flex-column { flex-direction: row !important; flex-wrap: wrap; gap: .15rem; }
  .sidebar .nav-link { padding: .3rem .5rem; font-size: .88rem; }
  .sidebar nav form { display: inline; }
  .sidebar .small.text-muted { display: none; }
  .env-strip { padding: .4rem 1rem; }
  .sidebar .nav-section, .sidebar .company-switch { display: none; }
  .sidebar .brand { margin-bottom: .5rem; }
  .main { padding: 1.25rem 1rem 2.5rem; }
}

/* Panneaux */
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.panel > h2:first-child, .panel > h3:first-child { margin-bottom: .9rem; }
.panel-tight { padding: 0; overflow: hidden; }

/* Registre d'indicateurs : une seule ligne réglée, pas de cartes */
.ledger { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); margin-bottom: 1.5rem; }
.ledger a { padding: 1rem 1.1rem; text-decoration: none; color: var(--ink); border-right: 1px solid var(--rule); }
.ledger a:last-child { border-right: 0; }
.ledger a:hover { background: var(--paper); }
.ledger .value { font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.ledger .label { color: var(--ink-soft); font-size: .85rem; }
.ledger .attention .value { color: var(--amber); }
.ledger .certified .value { color: var(--seal); }
.ledger .rejected .value { color: var(--red); }
@media (max-width: 700px) { .ledger { grid-template-columns: repeat(2, 1fr); } .ledger a { border-bottom: 1px solid var(--rule); } }

/* Tableaux en lignes de registre */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { border-bottom-color: var(--rule); padding: .6rem .75rem; vertical-align: middle; }
.table thead th { font-weight: 600; font-size: .82rem; color: var(--ink-soft); background: #FAFBFA; }
.table tbody tr:hover { background: #FAFCFB; }

/* Tampons de statut */
.stamp { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .55rem; border: 1.5px solid currentColor; border-radius: 4px; font-size: .8rem; font-weight: 600; white-space: nowrap; line-height: 1.4; }
.stamp-certified { color: var(--seal); background: var(--seal-tint); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--seal); }
.stamp-ready { color: #1F5FA0; background: #E6F0FA; }
.stamp-to_review, .stamp-uploaded { color: var(--ink-soft); background: #EEF1F3; }
.stamp-extracting, .stamp-certifying { color: var(--violet); background: var(--violet-tint); }
.stamp-rejected { color: var(--red); background: var(--red-tint); }
.stamp-comm_error { color: var(--red); background: #fff; border-style: dashed; }
.stamp-to_reconcile { color: var(--amber); background: var(--amber-tint); }
.stamp-env-sandbox { color: var(--violet); background: var(--violet-tint); }
.stamp-env-production { color: #fff; background: var(--ink); border-color: var(--ink); }

/* Boutons */
.btn { border-radius: var(--radius); font-weight: 600; }
.btn-primary { --bs-btn-bg: var(--seal); --bs-btn-border-color: var(--seal); --bs-btn-hover-bg: #0A5641; --bs-btn-hover-border-color: #0A5641; --bs-btn-active-bg: #084533; --bs-btn-disabled-bg: #7FA99B; --bs-btn-disabled-border-color: #7FA99B; }
.btn-outline-primary { --bs-btn-color: var(--seal); --bs-btn-border-color: var(--seal); --bs-btn-hover-bg: var(--seal); --bs-btn-hover-border-color: var(--seal); }
.btn-certify-production { background: var(--red); border-color: var(--red); color: #fff; }
.btn-certify-production:hover { background: #8F1C13; color: #fff; }

/* Formulaires */
.form-control, .form-select { border-color: #C5D1DB; }
.form-control:focus, .form-select:focus { border-color: var(--seal); box-shadow: 0 0 0 .2rem rgba(15, 107, 82, .18); }
.form-label { font-weight: 600; font-size: .88rem; margin-bottom: .3rem; }
.field-issue { font-size: .82rem; margin-top: .25rem; }
.field-issue.error { color: var(--red); }
.field-issue.warning { color: var(--amber); }
.conf { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; margin-left: .35rem; vertical-align: middle; }
.conf-high { background: var(--seal); }
.conf-mid { background: var(--amber); }
.conf-low { background: var(--red); }
.is-uncertain { background: var(--amber-tint); }
.is-missing { background: var(--red-tint); }
fieldset legend { font-size: 1rem; font-weight: 700; margin-bottom: .75rem; }

/* Lignes de facture éditables */
.lines-table input, .lines-table select, .lines-table textarea { min-width: 70px; }
.lines-table td { padding: .35rem .3rem !important; }
.lines-table .designation { min-width: 220px; }

/* Zone d'import */
.dropzone { border: 2px dashed #A9B8C5; border-radius: var(--radius); background: var(--surface); padding: 2.5rem 1.5rem; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone.is-over { border-color: var(--seal); background: var(--seal-tint); }
.dropzone .hint { color: var(--ink-soft); }
.preview-frame { width: 100%; height: 70vh; min-height: 420px; border: 1px solid var(--rule); border-radius: var(--radius); background: #EDEFF0; }

/* Sceau de certification */
.seal-block { display: grid; grid-template-columns: 140px 1fr; gap: 1.25rem; align-items: start; }
.seal-block img { width: 140px; height: 140px; image-rendering: pixelated; border: 1px solid var(--rule); border-radius: 4px; background: #fff; }
.signature { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; word-break: break-all; color: var(--ink-soft); }
@media (max-width: 600px) { .seal-block { grid-template-columns: 1fr; } }

/* Messages */
.alert { border-radius: var(--radius); border-width: 1px; }
.issues li { margin-bottom: .25rem; }
.basis { font-size: .72rem; color: var(--ink-soft); border: 1px solid var(--rule); border-radius: 3px; padding: 0 .3rem; margin-left: .35rem; }

/* Pages publiques */
.public-wrap { max-width: 1040px; margin: 0 auto; padding: 2.5rem 1.25rem; }
.auth-card { max-width: 460px; margin: 3rem auto; }
.hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 3rem; align-items: center; padding: 3rem 0 2rem; }
.hero h1 { font-size: 2.4rem; line-height: 1.12; max-width: 18ch; }
.hero p.lead { max-width: 52ch; color: var(--ink-soft); }
.hero-receipt { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.25rem 1.4rem; font-size: .88rem; }
.hero-receipt .row-line { display: flex; justify-content: space-between; border-bottom: 1px dotted var(--rule); padding: .35rem 0; font-variant-numeric: tabular-nums; }
.hero-receipt .band { margin-top: 1rem; padding-top: .9rem; border-top: 2px solid var(--seal); display: flex; gap: 1rem; align-items: center; }
.hero-receipt .qr-placeholder { width: 64px; height: 64px; border: 1.5px dashed var(--seal); border-radius: 4px; display: grid; place-items: center; font-size: .7rem; color: var(--seal); text-align: center; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border-top: 1px solid var(--rule); margin-top: 2rem; }
.steps div { padding: 1.1rem 1rem 0 0; }
.steps strong { display: block; margin-bottom: .25rem; }
@media (max-width: 800px) { .hero, .steps { grid-template-columns: 1fr; } .hero h1 { font-size: 1.9rem; } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print { .sidebar, .env-strip, .no-print { display: none !important; } .app-shell { display: block; } }

/* Parcours d'une facture */
.next-step { border-left: 4px solid var(--seal); }
.steps-track { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; list-style: none; padding: 0; margin: 0 0 1rem; font-size: .85rem; counter-reset: step; }
.steps-track li { counter-increment: step; color: var(--ink-soft); display: flex; align-items: center; gap: .4rem; }
.steps-track li::before { content: counter(step); width: 1.5rem; height: 1.5rem; border-radius: 50%; border: 1.5px solid currentColor; display: grid; place-items: center; font-weight: 700; font-size: .75rem; }
.steps-track li.done { color: var(--seal); }
.steps-track li.done::before { content: "✓"; background: var(--seal-tint); }
.steps-track li.current { color: var(--ink); font-weight: 700; }
.steps-track li.current::before { background: var(--ink); color: #fff; border-color: var(--ink); }
