:root {
  --bg: #f5f6f8; --panel: #ffffff; --line: #e4e7ec; --line-2: #eef0f3;
  --text: #101828; --muted: #667085; --faint: #98a2b3;
  --accent: #2f54eb; --accent-soft: #eef2ff; --accent-ink: #1d39c4;
  --green: #12805c; --green-soft: #e7f6ee; --amber: #b54708; --amber-soft: #fef3e2;
  --red: #c4320a; --red-soft: #fef0eb; --blue: #175cd3; --blue-soft: #eaf2ff;
  --grey: #475467; --grey-soft: #f2f4f7;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116; --panel: #161b22; --line: #262d36; --line-2: #1d232b;
    --text: #e6e9ee; --muted: #9aa4b2; --faint: #6b7584;
    --accent: #7c95ff; --accent-soft: #1d2442; --accent-ink: #a9b8ff;
    --green: #4ad295; --green-soft: #13291f; --amber: #f5b25b; --amber-soft: #2e2213;
    --red: #ff8a65; --red-soft: #321a14; --blue: #7cb1ff; --blue-soft: #15233a;
    --grey: #b4bcc8; --grey-soft: #20262e; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.num { font-variant-numeric: tabular-nums; }

/* Mise en page */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 650; letter-spacing: -.01em; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; display: block; object-fit: cover; }
.brand small { display: block; color: var(--muted); font-weight: 450; font-size: 12px; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: 8px; color: var(--text); font-weight: 500; }
.nav a:hover { background: var(--grey-soft); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent-ink); }
.nav .badge { background: var(--amber-soft); color: var(--amber); border-radius: 99px; padding: 0 8px; font-size: 12px; font-weight: 600; }
.nav-title { color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; margin: 20px 10px 6px; font-weight: 600; }
.main { padding: 26px 32px 60px; max-width: 1400px; width: 100%; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
h1 { font-size: 22px; letter-spacing: -.02em; margin: 0; font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
.sub { color: var(--muted); margin-top: 2px; }

/* Composants */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 18px 20px; }
.grid { display: grid; gap: 16px; }
.grid.socs { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.grid.two { grid-template-columns: 1.6fr 1fr; }
.soc-card { padding: 16px 18px; display: block; color: inherit; }
.soc-card:hover { text-decoration: none; border-color: var(--accent); }
.soc-card .nom { font-weight: 600; display: flex; justify-content: space-between; }
.soc-card .code { color: var(--faint); font-size: 12px; font-weight: 500; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.kpi .v { font-size: 20px; font-weight: 650; letter-spacing: -.02em; }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi.amber .v { color: var(--amber); } .kpi.green .v { color: var(--green); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 7px 13px; border-radius: 8px; font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--grey-soft); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.blue { background: var(--blue-soft); color: var(--blue); }
.chip.grey { background: var(--grey-soft); color: var(--grey); }
.chip.red { background: var(--red-soft); color: var(--red); }
.tag { display: inline-block; background: var(--grey-soft); color: var(--grey); border-radius: 6px; padding: 0 7px; font-size: 12px; font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; }
td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr.lien { cursor: pointer; }
tr.lien:hover td { background: var(--grey-soft); }
td.r, th.r { text-align: right; }
.cell-main { font-weight: 550; }
.cell-sub { color: var(--muted); font-size: 12px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search { min-width: 300px; flex: 1; max-width: 460px; }
.tabs { display: flex; gap: 4px; background: var(--grey-soft); padding: 3px; border-radius: 9px; }
.tabs a { padding: 5px 11px; border-radius: 7px; color: var(--muted); font-weight: 550; font-size: 13px; }
.tabs a.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* Fiche facture */
.fiche { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(360px, 1fr); gap: 18px; align-items: start; }
.viewer { height: calc(100vh - 120px); position: sticky; top: 16px; overflow: hidden; }
.viewer iframe { width: 100%; height: 100%; border: 0; display: block; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 550; }
label.f input, label.f select { width: 100%; font-size: 14px; color: var(--text); }
.montants input { text-align: right; font-variant-numeric: tabular-nums; }
.alert { border-radius: 9px; padding: 10px 13px; font-size: 13px; margin-bottom: 14px; display: flex; gap: 9px; align-items: flex-start; }
.alert.amber { background: var(--amber-soft); color: var(--amber); }
.alert.red { background: var(--red-soft); color: var(--red); }
.alert.blue { background: var(--blue-soft); color: var(--blue); }
.alert.green { background: var(--green-soft); color: var(--green); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.meta dt { color: var(--muted); } .meta dd { margin: 0; word-break: break-word; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.timeline li:last-child { border: 0; }
kbd { font: 11px ui-monospace, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; color: var(--muted); }

.drop { border: 2px dashed var(--line); border-radius: 14px; padding: 50px 20px; text-align: center; color: var(--muted); transition: .15s; cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.drop strong { color: var(--text); font-size: 16px; display: block; margin-bottom: 4px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; padding: 30px; }
.login input { width: 100%; margin: 6px 0 14px; padding: 10px 12px; }
.login .btn { width: 100%; justify-content: center; padding: 10px; }
.src-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.src-row:last-child { border: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.ok { background: var(--green); } .dot.ko { background: var(--red); } .dot.off { background: var(--faint); }
.pager { display: flex; gap: 6px; justify-content: flex-end; padding: 12px 14px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--text); color: var(--panel); padding: 10px 16px; border-radius: 10px; font-weight: 550; box-shadow: 0 8px 24px rgba(0,0,0,.2); }

@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .fiche, .grid.two { grid-template-columns: 1fr; }
  .viewer { position: static; height: 70vh; }
  .main { padding: 18px 16px 40px; }
  .search { min-width: 0; }
  .table-wrap { overflow-x: auto; }
}

/* ── v2 : plus simple, plus visuel ─────────────────────────────── */
.side { padding-top: 22px; }
.nav a { padding: 9px 12px; font-size: 14.5px; }
.nav a .ico { width: 18px; height: 18px; flex: none; opacity: .75; }
.nav a .lib { display: flex; align-items: center; gap: 10px; }
.nav-title { margin-top: 24px; }
.btn.big { padding: 12px 20px; font-size: 15px; border-radius: 11px; }
.hero { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 22px; }
.tile { border-radius: 16px; padding: 20px 22px; color: #fff; position: relative; overflow: hidden; box-shadow: 0 6px 18px rgba(16,24,40,.08); }
.tile .v { font-size: 38px; font-weight: 750; letter-spacing: -.03em; line-height: 1.1; }
.tile .l { opacity: .92; font-weight: 550; margin-top: 2px; }
.tile .s { opacity: .8; font-size: 13px; margin-top: 2px; }
.tile .btn { margin-top: 14px; background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.35); color: #fff; }
.tile .btn:hover { background: rgba(255,255,255,.28); }
.tile.amber { background: linear-gradient(135deg, #f59e0b, #ea580c); }
.tile.green { background: linear-gradient(135deg, #10b981, #0f766e); }
.tile.violet { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.tile::after { content: ""; position: absolute; right: -30px; top: -30px; width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,.12); }
.bar { height: 8px; background: var(--grey-soft); border-radius: 99px; overflow: hidden; margin-top: 12px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #8b5cf6); border-radius: 99px; }
.soc-card .pct { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; justify-content: space-between; }
.soc-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.done { text-align: center; padding: 40px 20px; }
.done .big { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.chip.violet { background: #ede9fe; color: #6d28d9; }
@media (prefers-color-scheme: dark) { .chip.violet { background: #2e2350; color: #c4b5fd; } }
.keys { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 10px; }
.reste { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.reste .bar { flex: 1; margin: 0; min-width: 120px; }
@media (max-width: 1000px) { .hero { grid-template-columns: 1fr; } }

/* ── Clôture mensuelle ── */
.onglets { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.onglets a { padding: 11px 18px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.onglets a:hover { color: var(--text); text-decoration: none; }
.onglets a.on { color: var(--accent); border-bottom-color: var(--accent); }
.onglets .nb { background: var(--amber-soft); color: var(--amber); border-radius: 99px; padding: 0 7px; font-size: 12px; margin-left: 4px; }
.onglets .nb:empty { display: none; }
table.grille td { padding: 6px; }
.case { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); color: var(--text); min-width: 170px; }
.case:hover { border-color: var(--accent); text-decoration: none; background: var(--accent-soft); }
.case .mini { font-size: 12px; color: var(--muted); }
.cands { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.cands form { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pioche { position: absolute; z-index: 1000; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 28px rgba(16,24,40,.16); max-height: 320px; overflow-y: auto; padding: 4px; }
.pioche .pi { display: flex; gap: 10px; padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.pioche .pi strong { font-variant-numeric: tabular-nums; min-width: 82px; }
.pioche .pi span { color: var(--muted); }
.pioche .pi:hover { background: var(--accent-soft); }
.pioche .pi.vide { color: var(--muted); cursor: default; }
.pioche .pi.creer { color: var(--accent); border-top: 1px solid var(--line); margin-top: 4px; }
.recherche-f { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; }
.recherche-f .res { flex-basis: 100%; display: flex; flex-direction: column; gap: 4px; }
.recherche-f .res form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.recherche-f .ligne-f { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 3px 6px; border-radius: 6px; cursor: pointer; }
.recherche-f .ligne-f:hover { background: var(--accent-soft); }
.recherche-f .selbar { flex-basis: 100%; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding-top: 4px; border-top: 1px solid var(--line); }
.side { display: flex; flex-direction: column; }
.deposer-btn { margin: 4px 12px 14px; justify-content: center; }
.onglets.reglages { margin-bottom: 18px; flex-wrap: wrap; }
.reglages + .top h1, .reglages ~ .top h1 { font-size: 18px; }
.reglages ~ .top { margin-top: 0; }
/* Accueil épuré */
.soc-ligne { display: grid; grid-template-columns: 200px 1fr auto; gap: 18px; align-items: center; padding: 16px 18px; }
.soc-ligne + .soc-ligne { border-top: 1px solid var(--line); }
.soc-ligne .nom { font-weight: 600; font-size: 15px; }
.soc-ligne .nom small { display: block; color: var(--muted); font-weight: 400; font-size: 12.5px; margin-top: 2px; }
.etapes { display: flex; gap: 6px; flex-wrap: wrap; }
.etape { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; font-size: 12.5px; background: var(--bg); color: var(--muted); text-decoration: none; border: 1px solid var(--line); }
.etape i { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; display: inline-block; }
.etape.ok { color: var(--text); } .etape.ok i { background: var(--green); }
.etape.todo { color: var(--text); border-color: var(--amber); } .etape.todo i { background: var(--amber); }
.mois-nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.mois-nav.socs a { border: 1px solid var(--line); background: var(--panel);  padding: 5px 10px; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: 13px; }
.mois-nav.socs a.on { border-color: var(--accent);  background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.resume { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 14px; font-size: 14px; }
.resume b { font-size: 18px; font-variant-numeric: tabular-nums; margin-right: 4px; }
@media (max-width: 760px) { .soc-ligne { grid-template-columns: 1fr; } }
.choix-lot { display: grid; gap: 8px; }
.choix-lot label { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.choix-lot label strong { min-width: 70px; }
.choix-lot label span { color: var(--muted); font-size: 13px; }
.choix-lot label.off { opacity: .55; cursor: default; }
.alert.violet { background: #f4f0ff; color: #5b34c7; display: flex; }
.chip.violet { background: #f4f0ff; color: #5b34c7; }
@media (prefers-color-scheme: dark) { .alert.violet, .chip.violet { background: #241a3d; color: #b9a4ff; } }

/* ── Mobile : barre du bas, tableaux en cartes, cibles tactiles ─────────────── */
.barre-bas, .mobile-seul, .pdfm, .pdfm-barre, .plus-actions { display: none; }
.shell { grid-template-columns: 240px minmax(0, 1fr); }
.main { min-width: 0; }
.table-wrap { overflow-x: auto; }
.top > div { min-width: 0; max-width: 100%; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hero-3 { grid-template-columns: repeat(3, 1fr); }
@media (hover: none) { .keys, .actions kbd { display: none; } }

@media (max-width: 1000px) {
  .side { display: none; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .main { min-width: 0; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .main { padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .barre-bas { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 900; background: var(--panel); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; box-shadow: 0 -4px 16px rgba(16,24,40,.06); }
  .barre-bas a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px 0; position: relative; -webkit-tap-highlight-color: transparent; }
  .barre-bas a:hover { text-decoration: none; }
  .barre-bas a svg { width: 23px; height: 23px; }
  .barre-bas a.on { color: var(--accent); }
  .barre-bas a b { position: absolute; top: 0; left: calc(50% + 6px); background: var(--amber); color: #fff; border-radius: 99px; font-size: 10.5px; line-height: 17px; min-width: 17px; padding: 0 5px; text-align: center; }
  .barre-bas a.deposer span { width: 44px; height: 44px; margin-top: -18px; border-radius: 50%; display: grid; place-items: center; color: #fff;
    background: linear-gradient(135deg, var(--accent), #8b5cf6); box-shadow: 0 6px 16px rgba(47,84,235,.35); }
  .barre-bas a.deposer span svg { width: 22px; height: 22px; }
  .mobile-seul { display: inline-flex; }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); left: 16px; right: 16px; text-align: center; }
  .top { margin-bottom: 16px; gap: 10px; }
  .top > div { flex-wrap: wrap; }
  .reste { flex-basis: 100%; }
  .hero-3 .tile { padding: 12px 12px; border-radius: 12px; }
  .hero-3 .tile .v { font-size: 26px; }
  .hero-3 .tile .s, .hero-3 .tile::after { display: none; }
  .hero-3 .tile .l { font-size: 12.5px; line-height: 1.3; }
  .hero.hero-3 { grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
  .pdfm, .pdfm-barre { display: block; }
}

@media (max-width: 760px) {
  body { font-size: 15px; }
  h1 { font-size: 20px; }
  /* iOS zoome sur tout champ < 16 px */
  input, select, textarea, label.f input, label.f select { font-size: 16px; }
  input:not([type=checkbox]):not([type=radio]), select { min-height: 42px; }
  .btn { min-height: 42px; padding: 9px 14px; }
  .btn.sm { min-height: 36px; padding: 6px 12px; font-size: 13.5px; }
  .card.pad { padding: 14px; }
  .alert { flex-wrap: wrap; }
  label.f { flex: 1 1 100%; min-width: 0; }
  label.f input, label.f select, label.f textarea { width: 100%; }
  .form-grid:not(.montants) { grid-template-columns: 1fr !important; }
  .form-grid.montants { gap: 8px; }
  .form-grid > .full, .form-grid > [style*="grid-column"] { grid-column: 1 / -1; }
  .pc-seul { display: none; }
  .defile-x { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .defile-x > * { flex: none; white-space: nowrap; }
  .onglets.reglages { flex-wrap: nowrap; scrollbar-width: none; }
  .onglets::-webkit-scrollbar { display: none; }
  .pc-seul-bloc, .sub.nom-fichier { display: none !important; }
  .defile-x::-webkit-scrollbar, .tabs::-webkit-scrollbar { display: none; }

  /* Filtres : recherche pleine largeur, onglets qui défilent */
  .filters { gap: 8px; }
  .search { min-width: 0; max-width: none; flex: 1 1 100%; }
  .filters select { flex: 1 1 40%; min-width: 0; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; max-width: 100%; scrollbar-width: none; }
  .tabs a { white-space: nowrap; padding: 8px 12px; }
  .filtres-liste .tabs { flex: 1 1 100%; }

  /* Tableaux -> cartes */
  .t-cartes, .t-cartes tbody { display: block; }
  .t-cartes tr:has(> th) { display: none; }
  .t-cartes tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
  .t-cartes tr:last-child { border-bottom: 0; }
  .t-cartes td { display: block; padding: 0; border: 0; order: 2; font-size: 13px; color: var(--muted); max-width: 100% !important; }
  .t-cartes td.m-a { order: 0; flex: 1 1 55%; min-width: 0; color: var(--text); font-size: 15px; }
  .t-cartes td.m-haut { order: 0; }
  .t-cartes tr::after { content: ""; order: 1; flex-basis: 100%; height: 0; }
  .t-cartes td.m-b { order: 1; margin-left: auto; text-align: right; color: var(--text); font-size: 15px; font-weight: 650; }
  .t-cartes td.m-plein { order: 3; flex-basis: 100%; color: var(--text); }
  .t-cartes td.m-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-start; text-align: left; white-space: normal !important; }
  .t-cartes td.m-actions form { display: inline-flex !important; }
  .t-cartes td.m-cache { display: none; }
  .t-cartes td[data-l] { display: flex; align-items: center; gap: 8px; flex: 1 1 45%; }
  .t-cartes td[data-l]::before { content: attr(data-l); font-size: 12px; color: var(--muted); white-space: nowrap; }
  .t-cartes td[data-l] input:not([type=checkbox]) { width: auto !important; flex: 1; min-width: 0; }
  .t-cartes .cell-sub { font-size: 12.5px; }
  .t-cartes tr.lien:active { background: var(--grey-soft); }
  .t-cartes tr.lien:hover td { background: none; }

  /* Pointage bancaire */
  .t-ops tr { padding: 14px; }
  .t-ops td.m-a { flex: 0 1 auto; }
  .t-ops td.m-haut { flex: 1; }
  .op-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
  .op-form input { width: auto !important; flex: 1 1 110px; min-width: 0; }
  .op-form input[name=libelle] { flex: 2 1 150px; }
  .cands form, .recherche-f .res form, .recherche-f .ligne-f { padding: 6px 0; border-bottom: 1px dashed var(--line-2); }
  .recherche-f input, .recherche-mobile input { width: auto !important; flex: 1 1 130px; min-width: 0; }
  .recherche-f .ligne-f input[type=checkbox] { flex: none; width: 20px; height: 20px; }
  .recherche-mobile > div:first-child strong { flex-basis: 100%; }

  /* Fiche facture : actions collées en bas, actions rares derrière ••• */
  .actions { position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 5; background: var(--panel);
    margin: 18px -14px -14px; padding: 10px 14px; border-radius: 0 0 var(--radius) var(--radius); box-shadow: 0 -6px 14px rgba(16,24,40,.06); }
  .actions .btn { flex: 1 1 auto; justify-content: center; }
  .actions #btn-valider { flex: 2 1 40%; font-size: 15.5px; }
  .actions .plus-actions { display: inline-flex; flex: 0 0 auto; letter-spacing: 1px; }
  .actions .sec { display: none; }
  .actions.ouvert .sec { display: inline-flex; flex-basis: 100%; }
  .actions.ouvert .plus-actions { background: var(--grey-soft); }
  .resume { gap: 10px 16px; }
  .resume .btn { flex: 1 1 auto; justify-content: center; }

  /* Accueil */
  .soc-ligne { gap: 10px; padding: 14px; }
  .soc-ligne .ouvrir, .soc-ligne > .btn { justify-content: center; width: 100%; }
  .etape { padding: 7px 11px; font-size: 13px; }

  /* Clôture mensuelle : 1re colonne figée, cases compactes */
  .grille-mois td:first-child, .grille-mois th:first-child { position: sticky; left: 0; z-index: 2; background: var(--panel); font-size: 13px; }
  .grille-mois .case { min-width: 120px; padding: 8px 9px; }
  .onglets a { padding: 11px 14px; }

  .drop { padding: 34px 16px; }
  .choix-lot label { padding: 12px; flex-wrap: wrap; }
  .btn.big { width: 100%; justify-content: center; }
  .pager { justify-content: space-between; }
  .meta { grid-template-columns: 1fr; gap: 0 0; } .meta dd { margin-bottom: 6px; }
}

/* Aperçu PDF mobile (pdf.js) */
@media (max-width: 1000px) {
  .viewer.mobile { height: auto; position: static; overflow: hidden; }
  .viewer.mobile iframe { display: none; }
  .viewer.mobile .pdfm { max-height: 58vh; overflow-y: auto; background: #525659; -webkit-overflow-scrolling: touch; }
  .viewer.mobile.grand .pdfm { max-height: none; }
  .pdfm canvas { display: block; width: 100%; height: auto; margin-bottom: 6px; background: #fff; }
  .pdfm-barre { display: flex !important; gap: 8px; padding: 8px; border-top: 1px solid var(--line); }
  .pdfm-barre .btn { flex: 1; justify-content: center; }
}

/* ── Photo d'un ticket ── */
.photo-form { display: grid; gap: 12px; max-width: 620px; }
.ph-titre { font-weight: 650; margin-bottom: 10px; }
.ph-socs, .ph-paie { display: flex; flex-wrap: wrap; gap: 8px; }
.ph-socs label, .ph-paie label { cursor: pointer; }
.ph-socs input, .ph-paie input { position: absolute; opacity: 0; pointer-events: none; }
.ph-socs span, .ph-paie span { display: inline-flex; align-items: center; min-height: 42px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px; font-weight: 550; background: var(--panel); }
.ph-socs input:checked + span, .ph-paie input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); box-shadow: 0 0 0 1px var(--accent) inset; }
.ph-socs input:focus-visible + span, .ph-paie input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.ph-prendre { width: 100%; justify-content: center; }
.ph-galerie { width: 100%; justify-content: center; margin-top: 8px; }
.ph-vignettes { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.ph-vignettes:empty { display: none; }
.ph-v { position: relative; width: 84px; height: 112px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--grey-soft); }
.ph-v img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-v button { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; }
.ph-envoyer { width: 100%; justify-content: center; }
.ph-ligne { padding: 12px 16px; color: inherit; }
.ph-ligne:hover { text-decoration: none; background: var(--grey-soft); }
.ph-ligne .r { text-align: right; white-space: nowrap; }
@media (max-width: 760px) { .ph-socs span, .ph-paie span { flex: 1; justify-content: center; } .ph-socs label, .ph-paie label { flex: 1 1 40%; display: flex; } }
@media (max-width: 760px) {
  .actions kbd, .keys { display: none; }
  .src-row { flex-wrap: wrap; }
  .src-row > span:last-child { justify-content: flex-start !important; }
}

/* Provenance d'une pièce */
.prov { display: inline-block; border-radius: 6px; padding: 0 7px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--grey-soft); color: var(--grey); vertical-align: 1px; }
.prov.pa { background: var(--green-soft); color: var(--green); }
.prov.mail { background: var(--blue-soft); color: var(--blue); }
.prov.scan, .prov.photo { background: var(--accent-soft); color: var(--accent-ink); }
.prov.depot, .prov.drive { background: var(--amber-soft); color: var(--amber); }

/* Sélecteurs à onglets (compte, société, filtre des opérations) : même look que les onglets de statut */
.tabs button { padding: 5px 11px; border-radius: 7px; color: var(--muted); font: inherit; font-weight: 550; font-size: 13px; background: none; border: 0; cursor: pointer; }
.tabs button[aria-pressed=true] { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.tabs button:hover { color: var(--text); }
.tabs a .nb, .tabs button .nb { display: inline-block; min-width: 18px; text-align: center; margin-left: 5px; padding: 0 6px; border-radius: 99px; font-size: 11.5px; background: var(--line); color: var(--muted); }
.tabs a .nb.a-faire, .tabs button .nb.a-faire { background: var(--amber-soft); color: var(--amber); }
.tabs a .nb.fait { background: var(--green-soft); color: var(--green); }
.tabs a.vide { opacity: .5; }
.tabs a.on, .tabs a[aria-current=page] { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.selecteur { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.selecteur > .cell-sub { min-width: 64px; }

/* Bandeau société : sur quelle société on travaille (couleur d'identité, toujours avec le nom) */
.bandeau-soc { display: flex; align-items: center; gap: 12px; padding: 10px 16px; margin-bottom: 14px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line); border-left: 8px solid var(--soc, var(--accent)); box-shadow: var(--shadow); }
.bandeau-soc .soc-nom { font-size: 22px; font-weight: 800; letter-spacing: -.01em; color: var(--soc, var(--accent)); text-transform: uppercase; }
.bandeau-soc .soc-detail { color: var(--muted); font-size: 13px; }
.soc-FD { --soc: #2563eb; } .soc-FP { --soc: #0e7490; } .soc-FG { --soc: #7c3aed; } .soc-SOLIBAT { --soc: #be185d; } .soc-SOLIFORM { --soc: #4338ca; } .soc-PERSO { --soc: #475569; }
.tag-soc { display: inline-block; padding: 1px 8px; border-radius: 6px; font-weight: 700; font-size: 12px; color: #fff; background: var(--soc, var(--accent)); }
