:root {
  --navy: #183742; --gold: #dcb253; --ink: #8c6f2a; --muted: #5f7179; --line: #e4dec6; --line2: #cfc8b0;
  --panel: #fbf8ea; --sand: #f6f3e6; --sky: #edf3fa; --ok: #24563a; --ok-bg: #e2efe5; --bad: #b23a3a; --bad-bg: #f6e3e3;
  --font: "Jost", "Segoe UI", system-ui, sans-serif; --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--sand); color: var(--navy); font: 15px/1.5 var(--font); min-height: 100vh; }
[hidden] { display: none !important; }
a { color: var(--ink); }
a:hover { color: var(--navy); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: .9em; }
button, input, select, textarea { font: inherit; color: inherit; }

.btn { height: 40px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--line2); background: #fff; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--navy); white-space: nowrap; }
.btn:hover { border-color: var(--navy); }
.btn.primaire { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; }
.btn.or { background: var(--gold); border-color: var(--gold); color: var(--navy); font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn.grand { height: 52px; font-size: 16px; justify-content: center; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.lien-btn { background: none; border: 0; padding: 4px 2px; color: var(--ink); text-decoration: underline; cursor: pointer; font-size: 14px; }
.lien-btn.danger { color: var(--bad); }

input[type=text], input[type=url], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search] {
  height: 44px; border: 1px solid var(--line2); border-radius: 6px; padding: 0 12px; background: #fff; width: 100%;
}
input:focus-visible, button:focus-visible, a:focus-visible, .depot:focus-within { outline: 2px solid var(--gold); outline-offset: 2px; }

/* En-tête */
.entete { background: var(--navy); color: #fff; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 10px 20px; border-bottom: 3px solid var(--gold); }
.marque { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 700; }
.produit { font-size: 15px; font-weight: 600; padding-left: 14px; border-left: 1px solid rgba(255,255,255,.3); }
.espace { flex: 1; }
.entete .qui { font-size: 14px; opacity: .85; }
.entete .btn { height: 36px; border: 0; }
.entete .btn[aria-current=page] { background: var(--gold); }

/* Connexion */
.connexion { min-height: calc(100vh - 60px); display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.connexion form { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--gold); border-radius: 10px; padding: 26px; display: flex; flex-direction: column; gap: 14px; }

.champ { display: flex; flex-direction: column; gap: 6px; }
.champ > label, .etiquette { font-size: 15px; font-weight: 700; }
.facultatif { font-weight: 400; color: var(--muted); }
.aide { font-size: 13px; color: var(--muted); }
.erreur { color: var(--bad); background: var(--bad-bg); border-radius: 6px; padding: 10px 12px; font-size: 14.5px; }

/* Nouveau partage */
.partage { display: flex; flex-wrap: wrap; gap: 28px; justify-content: center; align-items: flex-start; padding: 32px 16px 48px; }
.formulaire { flex: 1 1 560px; max-width: 640px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 26px 26px 22px; display: flex; flex-direction: column; gap: 22px; }
.saisie-lien { display: flex; align-items: center; gap: 8px; height: 56px; border: 2px solid var(--navy); border-radius: 8px; padding: 0 8px 0 14px; background: #fff; }
.saisie-lien input { border: 0; height: 100%; padding: 0; font-family: var(--mono); font-size: 14.5px; outline: none; min-width: 0; flex: 1; }
.saisie-lien:focus-within { outline: 2px solid var(--gold); outline-offset: 2px; }
.etat { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; border-radius: 6px; padding: 10px 14px; font-size: 14.5px; }
.etat.connu { background: var(--ok-bg); color: var(--ok); }
.etat.nouveau { background: var(--sky); }
.etat.attente { background: var(--panel); color: var(--muted); }
.depot { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 120px; border: 2px dashed var(--line2); border-radius: 8px; background: var(--panel); padding: 16px; text-align: center; cursor: pointer; }
.depot.survol { border-color: var(--navy); background: #f4efd8; }
.depot input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.depot strong { font-size: 15px; }
.fichiers { display: flex; flex-wrap: wrap; gap: 6px; }
.fichiers span { font-family: var(--mono); font-size: 12.5px; background: var(--sky); border-radius: 4px; padding: 2px 8px; }
.copie-actuelle { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; font-size: 14.5px; }
.copie-actuelle span { flex: 1 1 240px; color: var(--muted); }
.deux { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
legend { font-size: 15px; font-weight: 700; padding: 0; margin-bottom: 10px; }
.puces { display: flex; flex-wrap: wrap; gap: 8px; }
.puce { height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--line2); background: #fff; font-weight: 500; cursor: pointer; }
.puce[aria-pressed=true] { background: var(--navy); border-color: var(--navy); color: #fff; }
.petites .puce { height: 36px; padding: 0 12px; font-size: 14px; }
.ligne-code { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid #efeadb; padding-top: 18px; }
.ligne-code .txt { display: flex; flex-direction: column; gap: 2px; font-weight: 500; }
.interrupteur { flex: none; width: 52px; height: 30px; border-radius: 15px; border: 0; padding: 3px; display: flex; cursor: pointer; background: #8a9196; justify-content: flex-start; }
.interrupteur[aria-pressed=true] { background: var(--navy); justify-content: flex-end; }
.interrupteur span { width: 24px; height: 24px; border-radius: 12px; background: #fff; display: block; }
details.options summary { cursor: pointer; font-weight: 500; color: var(--ink); min-height: 32px; display: flex; align-items: center; }
details.options[open] summary { margin-bottom: 10px; }

.resultat { flex: 1 1 380px; max-width: 460px; display: flex; flex-direction: column; gap: 14px; }
.carte-lien { background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--gold); border-radius: 10px; padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.carte-lien .tete { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.url-boite { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px 0 12px; min-height: 50px; }
.url-boite span { flex: 1; min-width: 0; font-family: var(--mono); font-size: 13.5px; overflow-wrap: anywhere; padding: 8px 0; }
.infos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; font-size: 14px; }
.infos div { display: flex; flex-direction: column; gap: 2px; }
.infos .k { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.infos .v { font-weight: 600; }
.message { margin: 0; font-size: 14px; line-height: 1.55; background: #faf9f5; border-radius: 6px; padding: 12px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.boutons { display: flex; flex-wrap: wrap; gap: 8px; }
.note { font-size: 13.5px; color: var(--muted); padding: 0 4px; }
.attention { font-size: 13px; color: var(--ink); }

.badge { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 1px 9px; border-radius: 10px; white-space: nowrap; }
.badge.actif { background: var(--ok-bg); color: #2f6b45; }
.badge.expire, .badge.epuise { background: #efece2; color: var(--muted); }
.badge.revoque, .badge.archive { background: var(--bad-bg); color: var(--bad); }
.badge.code { background: var(--sky); color: var(--navy); font-weight: 500; }
.badge.source { background: var(--sky); color: var(--navy); }
.badge.fichier { background: #f1ede0; color: var(--muted); }

/* Documents */
.docs { display: flex; flex-wrap: wrap; align-items: stretch; min-height: calc(100vh - 60px); background: #fff; }
.docs aside { flex: 1 1 250px; max-width: 320px; background: var(--panel); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 12px; }
.liste-docs { display: flex; flex-direction: column; gap: 6px; }
.liste-docs button { text-align: left; display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border-radius: 6px; border: 1px solid transparent; background: transparent; cursor: pointer; }
.liste-docs button[aria-current=true] { background: #fff; border-color: var(--gold); }
.liste-docs .t { font-weight: 600; }
.liste-docs .s { font-size: 13px; color: var(--muted); }
.case { display: flex; align-items: center; gap: 8px; font-size: 14px; min-height: 32px; }
.docs main { flex: 999 1 560px; min-width: 0; padding: 24px 28px; display: flex; flex-direction: column; gap: 20px; }
.titre-doc { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 14px; }
.titre-doc h1 { font-size: 26px; }
.sous { font-size: 14px; color: var(--muted); }
.bandeau-source { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; background: var(--sky); border-radius: 6px; padding: 12px 16px; font-size: 14px; }
.bandeau-source span { flex: 1 1 300px; min-width: 0; overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stats div { background: var(--panel); border-left: 3px solid var(--gold); padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; }
.stats .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stats .v { font-size: 20px; font-weight: 700; }
.tableau { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; }
table { border-collapse: collapse; width: 100%; min-width: 680px; font-size: 14px; }
th { background: var(--navy); color: #fff; text-align: left; font-weight: 600; padding: 9px 12px; white-space: nowrap; }
td { padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: top; }
td .sous { font-size: 12.5px; }
.vide { color: var(--muted); padding: 24px; text-align: center; }
.panneau-lien { border: 1px solid var(--line); border-radius: 8px; padding: 18px; display: flex; flex-direction: column; gap: 14px; background: #fff; }
.fichiers-doc { font-size: 13px; color: var(--muted); }

/* Boîtes de dialogue */
dialog { border: 0; border-radius: 10px; padding: 0; width: min(560px, calc(100vw - 32px)); color: var(--navy); box-shadow: 0 20px 60px rgba(24,55,66,.25); }
dialog::backdrop { background: rgba(24,55,66,.4); }
dialog form, dialog .corps { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
dialog h2 { font-size: 20px; }
.journal { max-height: 60vh; overflow: auto; font-size: 13.5px; }
.journal table { min-width: 0; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14.5px; z-index: 10; box-shadow: 0 8px 24px rgba(0,0,0,.2); }

@media (max-width: 640px) {
  .deux, .infos { grid-template-columns: 1fr; }
  .formulaire { padding: 20px 16px; }
  .docs main { padding: 18px 16px; }
  .docs aside { max-width: none; border-right: 0; border-bottom: 1px solid var(--line); }
}
