/* Cabinet — cabinet.sanandreas.site
   Bordeaux et laiton : la plaque du cabinet. Le bleu du Bureau, le vert de la Cour et le prune du barreau
   restent aux autres sites. */
:root {
  --bg: #eef0ee;
  --surface: #ffffff;
  --surface2: #f6f7f5;
  --ink: #1d1e23;
  --muted: #5b5f68;
  --line: #d6d9d3;
  --accent: #6b1e2e;      /* bordeaux */
  --accent-ink: #ffffff;
  --accent-soft: #f4e7ea;
  --brass: #9a7631;       /* laiton */
  --brass-soft: #f3ead6;
  --side: #23181b;        /* le cuir de la plaque */
  --side-ink: #efe6dc;
  --side-muted: #b9aaa0;
  --ok: #2c6b45; --ok-soft: #e3f1e8;
  --warn: #8a5a00; --warn-soft: #fbf0d9;
  --bad: #a3271b; --bad-soft: #fbe5e2;
  --focus: #9a7631;
  --radius: 8px;
  --ui: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Spectral", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141518; --surface: #1c1e22; --surface2: #23262b; --ink: #ecebe6; --muted: #a6a8ae; --line: #33363c;
    --accent: #e0909f; --accent-ink: #20090e; --accent-soft: #3a2228; --brass: #d3ae62; --brass-soft: #362d1c;
    --side: #0f0d0e; --side-ink: #ece4da; --side-muted: #a2958c;
    --ok: #79c99a; --ok-soft: #1d3326; --warn: #e5b45b; --warn-soft: #3a2f17; --bad: #f08a7c; --bad-soft: #3d1f1b;
    --focus: #d3ae62; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141518; --surface: #1c1e22; --surface2: #23262b; --ink: #ecebe6; --muted: #a6a8ae; --line: #33363c;
  --accent: #e0909f; --accent-ink: #20090e; --accent-soft: #3a2228; --brass: #d3ae62; --brass-soft: #362d1c;
  --side: #0f0d0e; --side-ink: #ece4da; --side-muted: #a2958c;
  --ok: #79c99a; --ok-soft: #1d3326; --warn: #e5b45b; --warn-soft: #3a2f17; --bad: #f08a7c; --bad-soft: #3d1f1b;
  --focus: #d3ae62; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--ui); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font: 600 1.6rem/1.2 var(--serif); }
h2 { font-size: 1.1rem; font-weight: 600; }
h3 { font-size: .98rem; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
fieldset { min-width: 0; }
label.champ, .redaction > *, .grille2 > *, .grille3 > * { min-width: 0; }

/* ------------------------------------------------------------ Accueil (connexion) */
.porte { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.porte-carte { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.porte-plaque { background: var(--side); color: var(--side-ink); padding: 28px 28px 22px; border-bottom: 3px solid var(--brass); }
.porte-plaque .p-titre { font: 600 1.7rem/1.1 var(--serif); }
.porte-plaque .p-sous { color: var(--side-muted); margin-top: 6px; font-size: .92rem; }
.porte-corps { padding: 22px 28px 26px; display: grid; gap: 14px; }
.onglets-porte { display: flex; gap: 4px; background: var(--surface2); padding: 4px; border-radius: 8px; }
.onglets-porte button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.onglets-porte button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ------------------------------------------------------------ Formulaires */
label.champ { display: grid; gap: 4px; font-size: .88rem; color: var(--muted); }
label.champ > span.aide { font-size: .8rem; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=datetime-local], input[type=date], input[type=search], input[type=url], select, textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; color: var(--ink);
}
textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--brass); outline: none; box-shadow: 0 0 0 3px var(--brass-soft); }
.grille2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grille3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 720px) { .grille2, .grille3 { grid-template-columns: 1fr; } }
.ligne { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ligne.fin { justify-content: flex-end; }
.ligne.entre { justify-content: space-between; }
.pile { display: grid; gap: 12px; }

.btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 7px 14px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.prim { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.prim:hover { filter: brightness(1.08); }
.btn.laiton { background: var(--brass); border-color: var(--brass); color: #fff; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.petit { padding: 4px 10px; font-size: .86rem; }
.btn.lien { border: 0; background: none; color: var(--accent); padding: 0; text-decoration: underline; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.message { padding: 10px 12px; border-radius: 6px; font-size: .9rem; }
.message.erreur { background: var(--bad-soft); color: var(--bad); }
.message.ok { background: var(--ok-soft); color: var(--ok); }
.message.info { background: var(--brass-soft); color: var(--ink); }

/* ------------------------------------------------------------ Application */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.cote { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.plaque { padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.plaque-nom { font: 600 1.28rem/1.15 var(--serif); }
.plaque-filet { height: 3px; width: 44px; background: var(--brass); margin: 10px 0 8px; border-radius: 2px; }
.plaque-sous { color: var(--side-muted); font-size: .84rem; }
.nav { padding: 10px 8px; display: grid; gap: 2px; overflow-y: auto; flex: 1; align-content: start; }
.nav button { display: flex; align-items: center; gap: 10px; text-align: left; border: 0; background: transparent; color: var(--side-ink); padding: 9px 12px; border-radius: 6px; cursor: pointer; font-size: .95rem; opacity: .82; }
.nav button:hover { background: rgba(255,255,255,.06); opacity: 1; }
.nav button[aria-current="page"] { background: rgba(255,255,255,.1); opacity: 1; box-shadow: inset 3px 0 0 var(--brass); }
.nav .pastille { margin-left: auto; background: var(--brass); color: #1b1408; font-size: .74rem; font-weight: 700; padding: 1px 7px; border-radius: 10px; }
.nav svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.moi { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); display: grid; gap: 6px; font-size: .88rem; }
.moi .nom { font-weight: 600; }
.moi .actions { display: flex; gap: 12px; flex-wrap: wrap; }
.moi .actions button { background: none; border: 0; color: var(--side-muted); padding: 0; cursor: pointer; text-decoration: underline; font-size: .84rem; }

.principal { min-width: 0; padding: 24px 28px 60px; }
.tete { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.tete .sous { color: var(--muted); margin-top: 4px; }

/* Insigne de grade */
.grade { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 600; padding: 2px 9px 2px 7px; border-radius: 20px; background: var(--surface2); border: 1px solid var(--line); color: var(--ink); white-space: nowrap; }
.grade::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--g, var(--muted)); }
.grade.g-patron { --g: #b38a3a; background: var(--brass-soft); border-color: color-mix(in srgb, #b38a3a 40%, transparent); }
.grade.g-associe { --g: #7a2235; }
.grade.g-senior { --g: #1f6a6a; }
.grade.g-junior { --g: #3d5a99; }
.grade.g-assistant { --g: #6b7a2e; }
.grade.g-detective { --g: #4b4f57; }
.grade.g-homme_de_main { --g: #7a4a24; }
.cote .grade { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.12); color: var(--side-ink); }

/* Panneaux */
.panneau { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panneau > .p-tete { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panneau > .p-corps { padding: 14px 16px; }
.panneau + .panneau { margin-top: 16px; }
.colonnes { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.colonnes > .panneau + .panneau { margin-top: 0; }

/* Chiffres du tableau de bord : une seule ligne, sobre */
.compteurs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 16px; overflow: hidden; }
.compteurs > div { padding: 12px 16px; border-right: 1px solid var(--line); }
.compteurs > div:last-child { border-right: 0; }
.compteurs .v { font: 600 1.35rem/1.2 var(--serif); font-variant-numeric: tabular-nums; }
.compteurs .l { color: var(--muted); font-size: .84rem; }
.compteurs .v.neg { color: var(--bad); }

/* Listes */
.liste { list-style: none; margin: 0; padding: 0; }
.liste > li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.liste > li:last-child { border-bottom: 0; }
.liste .quand { flex: none; width: 112px; color: var(--muted); font-size: .84rem; font-variant-numeric: tabular-nums; }
.liste .quoi { flex: 1; min-width: 0; }
.liste button.ouvrir { all: unset; cursor: pointer; font-weight: 600; }
.liste button.ouvrir:hover { text-decoration: underline; }
.liste button.ouvrir:focus-visible { outline: 2px solid var(--focus); }
.vide { color: var(--muted); padding: 18px 0; text-align: center; }

/* Tableaux */
.tableau-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: .82rem; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr.cliquable { cursor: pointer; }
table.t tr.cliquable:hover td { background: var(--surface2); }
table.t td.ref { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); font-size: .86rem; }

/* États */
.etat { display: inline-block; font-size: .78rem; font-weight: 600; padding: 1px 8px; border-radius: 4px; background: var(--surface2); color: var(--muted); white-space: nowrap; }
.etat.vert { background: var(--ok-soft); color: var(--ok); }
.etat.orange { background: var(--warn-soft); color: var(--warn); }
.etat.rouge { background: var(--bad-soft); color: var(--bad); }
.etat.bordeaux { background: var(--accent-soft); color: var(--accent); }
.etat.laiton { background: var(--brass-soft); color: var(--warn); }

/* Filtres */
.filtres { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filtres input[type=search] { max-width: 280px; }
.filtres select { width: auto; }

/* Fenêtres */
dialog.fen { border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--ink); }
dialog.fen.large { width: min(1180px, calc(100vw - 24px)); }
dialog.fen::backdrop { background: rgba(20, 12, 14, .55); }
.fen-tete { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.fen-corps { padding: 16px 18px; display: grid; gap: 14px; }
.fen-pied { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding: 12px 18px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); }
.fen-pied .gauche { margin-right: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.fermer { border: 0; background: none; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; }

/* Fiche (vue dossier) */
.fiche-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 18px; }
.fiche-meta dt { color: var(--muted); font-size: .8rem; }
.fiche-meta dd { margin: 0; }
.historique { font-size: .86rem; }
.historique li { padding: 5px 0; border-bottom: 1px dashed var(--line); list-style: none; }
.historique { padding: 0; margin: 0; }
.confidentiel { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 10px 12px; border-radius: 0 6px 6px 0; }

/* Éditeur de courrier : formulaire à gauche, papier à droite */
.redaction { display: grid; grid-template-columns: minmax(300px, 400px) 1fr; gap: 18px; align-items: start; }
.redaction .form { display: grid; gap: 12px; }
.redaction .papier-wrap { background: var(--surface2); border: 1px solid var(--line); border-radius: 8px; padding: 16px; position: sticky; top: 64px; max-height: calc(100vh - 160px); overflow: auto; }
@media (max-width: 900px) { .redaction { grid-template-columns: 1fr; } .redaction .papier-wrap { position: static; max-height: none; } }
.compte-trous { font-size: .86rem; }

/* Le papier du courrier : toujours clair, même en sombre */
.lettre { background: #fffefb; color: #1b1b1f; font: 15px/1.6 var(--serif); padding: 40px 46px; max-width: 760px; margin: 0 auto; border: 1px solid #e3e0d8; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.lettre .l-entete { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 18px; border-bottom: 2px solid #6b1e2e; margin-bottom: 18px; }
.lettre .l-nom { font-size: 1.32rem; font-weight: 600; color: #6b1e2e; }
.lettre .l-sous { font-style: italic; color: #5d5a55; }
.lettre .l-coord { font-size: .86rem; color: #5d5a55; margin-top: 6px; font-family: var(--ui); }
.lettre .l-dest { text-align: left; min-width: 220px; max-width: 300px; padding-top: 34px; }
.lettre .l-dest-nom { font-weight: 600; }
.lettre .l-lieu { text-align: right; margin: 6px 0 14px; }
.lettre .l-refs { margin: 0 0 20px; font-family: var(--ui); font-size: .88rem; display: grid; gap: 2px; }
.lettre .l-refs > div { display: grid; grid-template-columns: 140px 1fr; gap: 10px; }
.lettre .l-refs dt { color: #6d6a64; }
.lettre .l-refs dd { margin: 0; }
.lettre .l-objet dd { font-weight: 600; }
.lettre .l-corps p { margin: 0 0 .85em; text-align: justify; hyphens: auto; }
.lettre .l-corps ul { margin: 0 0 .85em; padding-left: 1.3em; }
.lettre .l-signature { display: flex; justify-content: flex-end; margin-top: 28px; }
.lettre .l-sign-bloc { text-align: center; min-width: 260px; position: relative; }
.lettre .l-sceau { width: 108px; height: 108px; object-fit: contain; display: block; margin: 0 auto 4px; opacity: .92; }
.lettre .l-sign-nom { font-weight: 600; }
.lettre .l-sign-qual, .lettre .l-redige { font-size: .9rem; color: #5d5a55; }
.lettre .l-sign-quand { font-family: var(--ui); font-size: .8rem; color: #6b1e2e; margin-top: 6px; border-top: 1px solid #c9b48a; padding-top: 4px; }
.lettre .l-nonsigne { color: #a3271b; }
.lettre .l-copie, .lettre .l-pj { margin-top: 18px; font-size: .9rem; }
.lettre .l-mentions { margin-top: 26px; padding-top: 8px; border-top: 1px solid #e3e0d8; font: .76rem/1.4 var(--ui); color: #6d6a64; }
.lettre mark.trou { background: #fbe39b; color: #5a3b00; padding: 0 2px; border-radius: 2px; }
.lettre .f-titre { font: 600 1.2rem/1.3 var(--serif); margin: 0 0 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.lettre .f-etat { font: 600 .74rem var(--ui); padding: 2px 8px; border-radius: 4px; background: #f1ede4; color: #6d6a64; }
.lettre .f-etat.f-payee { background: #e3f1e8; color: #2c6b45; }
.lettre .f-etat.f-emise { background: #fbf0d9; color: #8a5a00; }
.lettre .f-etat.f-annulee { background: #fbe5e2; color: #a3271b; }
.lettre .f-table { width: 100%; border-collapse: collapse; font: .92rem var(--ui); margin: 10px 0 14px; }
.lettre .f-table th, .lettre .f-table td { padding: 7px 8px; border-bottom: 1px solid #e3e0d8; text-align: left; }
.lettre .f-table .num { text-align: right; }
.lettre .f-table tfoot th { font-size: 1rem; border-bottom: 2px solid #6b1e2e; }
.lettre .f-paye { font-family: var(--ui); color: #2c6b45; font-weight: 600; }
@media (max-width: 640px) { .lettre { padding: 22px 18px; } .lettre .l-entete { flex-direction: column; } .lettre .l-dest { padding-top: 0; } .lettre .l-refs > div { grid-template-columns: 1fr; gap: 0; } }

/* Lignes de facture */
.lignes-fac { display: grid; gap: 6px; }
.lignes-fac .lf { display: grid; grid-template-columns: 1fr 70px 110px 34px; gap: 6px; }

/* Graphique de caisse */
.barres { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 8px; }
.barres .b { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; min-width: 0; position: relative; }
.barres .b i { display: block; border-radius: 2px 2px 0 0; }
.barres .b i.r { background: var(--ok); }
.barres .b i.d { background: var(--accent); }
.barres-l { display: flex; gap: 6px; font-size: .74rem; color: var(--muted); }
.barres-l span { flex: 1; text-align: center; min-width: 0; overflow: hidden; }
.legende { display: flex; gap: 14px; font-size: .82rem; color: var(--muted); }
.legende i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* Annuaire */
.annuaire { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.carte-membre { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 6px; }
.carte-membre .n { font-weight: 600; }

/* Sous-onglets */
.sous-onglets { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.sous-onglets button { border: 0; background: none; padding: 9px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.sous-onglets button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brass); font-weight: 600; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--side); color: var(--side-ink); padding: 10px 16px; border-radius: 8px; z-index: 1000; font-size: .92rem; max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.25); }

/* Téléphone */
.burger { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .cote { position: static; height: auto; }
  .plaque { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; }
  .plaque-filet, .plaque-sous { display: none; }
  .burger { display: inline-block; background: none; border: 1px solid rgba(255,255,255,.2); color: var(--side-ink); border-radius: 6px; padding: 5px 10px; cursor: pointer; }
  .nav { display: none; }
  .cote.ouvert .nav { display: grid; }
  .moi { display: none; }
  .cote.ouvert .moi { display: grid; }
  .principal { padding: 16px 16px 60px; }
}

/* Impression : le seul papier */
@media print {
  body { background: #fff; }
  body.imprime > *:not(#impression) { display: none !important; }
  #impression { display: block !important; }
  #impression .lettre { border: 0; box-shadow: none; padding: 0; max-width: none; }
  .lettre mark.trou { background: none; }
}
#impression { display: none; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
