/* PEWPEW — feuille de style unique, sans dépendance externe. Mobile d'abord. */
:root {
  --bg: #f3f4f1;
  --surface: #ffffff;
  --surface-2: #f7f8f5;
  --text: #1c2320;
  --muted: #6b746f;
  --border: #dde1dc;
  --primary: #2f5d46;
  --primary-ink: #ffffff;
  --primary-soft: #e3eee7;
  --accent: #c2772b;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --warn: #9a6200;
  --warn-soft: #fdf1d8;
  --ok: #2e7d4f;
  --ok-soft: #e2f3e8;
  --info-soft: #e6eef8;
  --nav-bg: #1f2a24;
  --nav-ink: #d8e0db;
  --nav-active: #3b7358;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --chart-1: #2f6f4f; --chart-2: #c2772b; --chart-3: #3f6fb0; --chart-4: #8c4f9c;
  --chart-5: #b8a31f; --chart-6: #2a9aa0; --chart-7: #b34a4a; --chart-8: #7a8580;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131815; --surface: #1b211e; --surface-2: #222a26; --text: #e5ebe7; --muted: #95a09a; --border: #313b36;
    --primary: #5aa47c; --primary-ink: #0d1510; --primary-soft: #203a2d; --accent: #e09a52;
    --danger: #ef7a72; --danger-soft: #3a1f1d; --warn: #e5b458; --warn-soft: #3a2f16; --ok: #6cc592; --ok-soft: #1c3526; --info-soft: #1d2a3a;
    --nav-bg: #0f1411; --nav-ink: #c3cdc7; --nav-active: #2d5c45;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    --chart-1: #5fb88a; --chart-2: #e59d55; --chart-3: #6e9ee0; --chart-4: #b681c4;
    --chart-5: #d8c64a; --chart-6: #4fc2c7; --chart-7: #e07b7b; --chart-8: #9aa5a0;
    color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0; line-height: 1.25; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; display: flex; align-items: center; gap: .5rem; }
h3 { font-size: .95rem; margin: 1rem 0 .5rem; }
code, .mono { font-family: var(--mono); font-size: .92em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.2rem 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.prose { white-space: normal; overflow-wrap: anywhere; }
.count { font-size: .75rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; padding: 0 .5rem; color: var(--muted); font-weight: 500; }

/* ---------- Barre supérieure & navigation ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .75rem; padding: .55rem 1rem; padding-top: max(.55rem, env(safe-area-inset-top)); background: var(--nav-bg); color: var(--nav-ink); }
.brand { display: flex; align-items: center; gap: .5rem; color: #fff; font-weight: 700; letter-spacing: .04em; }
.brand:hover { text-decoration: none; }
.usernav { margin-left: auto; display: flex; align-items: center; gap: .9rem; font-size: .9rem; }
.usernav a, .usernav .link-btn { color: var(--nav-ink); }
.usernav a.active { color: #fff; font-weight: 600; }
.nav-toggle { display: none; background: none; border: 0; padding: .4rem; cursor: pointer; }
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--nav-ink); margin: 4px 0; border-radius: 2px; transition: .2s; }
.shell { display: flex; flex: 1; min-height: 0; }
.sidenav { width: 215px; flex-shrink: 0; background: var(--nav-bg); padding: .75rem .5rem; }
.sidenav ul { list-style: none; margin: 0; padding: 0; position: sticky; top: 3.6rem; }
.sidenav a { display: flex; align-items: center; gap: .65rem; padding: .55rem .75rem; border-radius: 8px; color: var(--nav-ink); font-size: .93rem; }
.sidenav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidenav a.active { background: var(--nav-active); color: #fff; font-weight: 600; }
.ico { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.only-mobile, .nav-sep { display: none; }
.main { flex: 1; min-width: 0; padding: 1.25rem 1.5rem 5rem; max-width: 1280px; }
.main.solo { margin: 0 auto; width: 100%; max-width: 760px; padding-top: 3rem; }
.foot { text-align: center; color: var(--muted); font-size: .78rem; padding: 1rem; }

/* ---------- En-têtes de page ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .75rem 1rem; margin-bottom: 1.1rem; }
.page-head .sub { margin: .25rem 0 0; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.page-actions.right { justify-content: flex-end; margin-bottom: .75rem; }

/* ---------- Cartes & grilles ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .table { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.grid-2.top { align-items: start; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.tile { display: block; color: inherit; transition: border-color .15s, transform .15s; }
.tile:hover { border-color: var(--primary); text-decoration: none; transform: translateY(-1px); }
.tile h3 { margin: 0 0 .25rem; font-size: 1rem; }
.tile.dim { opacity: .6; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; margin: .5rem 0; }
.chip { font-size: .78rem; background: var(--primary-soft); color: var(--text); border-radius: 99px; padding: .1rem .55rem; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; display: flex; flex-direction: column; color: inherit; box-shadow: var(--shadow); }
a.kpi:hover { border-color: var(--primary); text-decoration: none; }
.kpi-v { font-size: 1.7rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-v.sm { font-size: 1.15rem; padding: .25rem 0; }
.kpi-l { color: var(--muted); font-size: .82rem; }
.trend { font-size: .76rem; margin-top: .2rem; font-weight: 600; }
.trend.up { color: var(--ok); } .trend.down { color: var(--danger); }

/* ---------- Listes / dl ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .5rem 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.dl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .8rem 1.2rem; margin: 0; }
.dl-grid dt { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.dl-grid dd { margin: .1rem 0 0; overflow-wrap: anywhere; }
.steps li { margin: .5rem 0; }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--muted); }
.dot.warn { background: var(--warn); } .dot.danger { background: var(--danger); }

/* ---------- Badges ---------- */
.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: .1rem .5rem; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); vertical-align: middle; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.muted { opacity: .8; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; font: inherit; font-size: .9rem; font-weight: 600; padding: .5rem .95rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; line-height: 1.2; min-height: 38px; white-space: nowrap; }
.btn:hover { border-color: var(--primary); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger.ghost { background: transparent; color: var(--danger); border-color: var(--danger-soft); }
.btn.sm { font-size: .82rem; padding: .3rem .65rem; min-height: 30px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
form.inline { display: inline; }
.row-actions { white-space: nowrap; text-align: right; }

/* ---------- Formulaires ---------- */
fieldset { border: 0; border-top: 1px solid var(--border); margin: 0 0 .5rem; padding: 1rem 0 .25rem; min-width: 0; }
fieldset:first-of-type { border-top: 0; padding-top: 0; }
legend { font-weight: 700; font-size: .95rem; padding: 0 .4rem 0 0; }
.fields { display: flex; flex-wrap: wrap; gap: .85rem 1rem; align-items: flex-start; }
.field { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.field label { font-size: .83rem; font-weight: 600; color: var(--muted); }
.field.w-xs { width: 7.5rem; } .field.w-s { width: 11rem; } .field.w-m { width: 17rem; } .field.w-l { width: 100%; }
.req { color: var(--danger); }
input, select, textarea { font: inherit; font-size: 16px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .65rem; min-height: 40px; width: 100%; max-width: 100%; }
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
input[type=checkbox], input[type=radio] { width: 1.15rem; height: 1.15rem; min-height: 0; accent-color: var(--primary); margin: 0; flex-shrink: 0; }
input[type=file] { padding: .4rem; }
input.w-s, select.w-s { width: 9rem; } input.w-xs { width: 6rem; }
.check { display: inline-flex; align-items: center; gap: .5rem; font-weight: 500 !important; color: var(--text) !important; font-size: .92rem !important; cursor: pointer; }
.input-group { display: flex; align-items: stretch; }
.input-group input { border-radius: 0; flex: 1; min-width: 0; }
.input-group input:first-child { border-radius: 8px 0 0 8px; }
.input-group input:last-child { border-radius: 0 8px 8px 0; }
.addon { display: flex; align-items: center; padding: 0 .6rem; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); font-size: .85rem; white-space: nowrap; }
.addon:first-child { border-right: 0; border-radius: 8px 0 0 8px; }
.addon:last-child { border-left: 0; border-radius: 0 8px 8px 0; }
.help { color: var(--muted); font-size: .78rem; }
.error { color: var(--danger); font-size: .8rem; font-weight: 600; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.ref-new { margin-top: .35rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.actions.sticky { position: sticky; bottom: 0; background: var(--surface); padding: .75rem 0 calc(.5rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); margin-bottom: -.5rem; z-index: 5; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; align-items: center; }
.filters input[type=search] { width: 18rem; }
.filters select { width: auto; }
.spec-form { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; align-items: center; }
.spec-form input[type=text], .spec-form select { width: auto; flex: 1 1 9rem; }
.spec-form input[type=date] { width: auto; flex: 0 0 auto; }
.add-block > summary { list-style: none; margin: .5rem 0; }
.add-block > summary::-webkit-details-marker { display: none; }
.add-block[open] > summary { margin-bottom: 1rem; }
details.card.add-block { padding-top: .6rem; padding-bottom: .6rem; }

/* Sélecteur d'accessoires (setups) */
.acc-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .6rem; }
.acc-item { border: 1px solid var(--border); border-radius: 8px; padding: .6rem; display: flex; flex-direction: column; gap: .4rem; background: var(--surface-2); }
.acc-item.on { border-color: var(--primary); background: var(--primary-soft); }
.acc-item .check { align-items: flex-start; }
.acc-item input[type=text] { min-height: 34px; padding: .3rem .5rem; font-size: .88rem; }

/* Lignes de séance */
.lines { display: flex; flex-direction: column; gap: .6rem; margin-bottom: .75rem; }
.line { position: relative; display: flex; flex-wrap: wrap; gap: .6rem .8rem; padding: .75rem 2.4rem .75rem .75rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.line-del { position: absolute; top: .4rem; right: .4rem; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--danger); font-size: 1.1rem; cursor: pointer; line-height: 1; }

/* ---------- Tableaux ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--surface-2); font-weight: 600; }
.table th.num, .table td.num { text-align: right; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot th { background: var(--surface-2); color: var(--text); font-size: .9rem; border-top: 2px solid var(--border); }
.table.clickable tbody tr { cursor: pointer; }
.table.clickable tbody tr:hover { background: var(--surface-2); }
.table.compact th, .table.compact td { padding: .4rem .5rem; }
.card:not(.flush) > .table:not(.compact) { margin: 0 -1.2rem; width: calc(100% + 2.4rem); }
.ficon { display: inline-block; font-size: .62rem; font-weight: 800; background: var(--primary-soft); color: var(--primary); border-radius: 4px; padding: .1rem .3rem; vertical-align: middle; }

/* ---------- Onglets ---------- */
.tabs { display: flex; gap: .25rem; overflow-x: auto; margin-bottom: 1rem; border-bottom: 1px solid var(--border); scrollbar-width: none; }
.tabs a { padding: .55rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 600; font-size: .9rem; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Messages ---------- */
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .92rem; background: var(--info-soft); border-left: 4px solid var(--primary); }
.flash.success { background: var(--ok-soft); border-color: var(--ok); }
.flash.error { background: var(--danger-soft); border-color: var(--danger); }
.flash.warn { background: var(--warn-soft); border-color: var(--warn); }
.empty { text-align: center; padding: 2.5rem 1rem; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted); }
.danger-zone { border-color: var(--danger-soft); }

/* ---------- Galerie ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.gallery a { display: block; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
img.preview { max-width: 100%; max-height: 360px; border-radius: 8px; border: 1px solid var(--border); }

/* ---------- Graphiques ---------- */
.chart { width: 100%; min-height: 240px; position: relative; }
.chart.sm { min-height: 180px; }
.chart svg { display: block; width: 100%; overflow: visible; }
details.data { margin-top: .5rem; font-size: .88rem; }
details.data summary { cursor: pointer; color: var(--muted); }
pre.log { font-size: .75rem; max-height: 320px; overflow: auto; background: var(--surface-2); padding: .75rem; border-radius: 8px; white-space: pre-wrap; }

/* ---------- Connexion / installation ---------- */
.login-box { max-width: 400px; margin: 0 auto; padding: 1.75rem; }
.login-brand { text-align: center; margin-bottom: 1.25rem; }
.login-brand h1 { margin-top: .5rem; letter-spacing: .05em; }
.login-box .field { margin-bottom: .9rem; }
.install { max-width: 760px; margin: 0 auto; }
.checks { list-style: none; padding: 0; }
.checks li { padding: .2rem 0; }
.checks .ok { color: var(--ok); } .checks .ko { color: var(--danger); font-weight: 600; } .checks .warn { color: var(--warn); }

/* ---------- v1.1 : munitions, résultats, entretien, 2FA, rapports ---------- */
.w-auto { width: auto !important; flex: 0 0 auto !important; }
.spec-form .w-xs { width: 6.5rem; flex: 0 0 6.5rem; }
.spec-form .input-group.w-auto input { width: 6rem; }
td.neg { color: var(--danger); } td.pos { color: var(--ok); }
.line-results { width: 100%; border-top: 1px dashed var(--border); padding-top: .4rem; }
.line-results > summary { cursor: pointer; font-size: .83rem; color: var(--muted); font-weight: 600; margin-bottom: .4rem; }
.line-results[open] > summary { margin-bottom: .6rem; }
.addon-select { width: auto; min-width: 4.6rem; border-radius: 0 8px 8px 0; border-left: 0; background: var(--surface-2); padding: .3rem; font-size: .85rem; }
.input-group input + .addon + input { border-radius: 0 8px 8px 0; }
.progress { height: 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; margin: .3rem 0 .8rem; }
.progress span { display: block; height: 100%; width: 0; background: var(--ok); border-radius: 99px; transition: width .4s; }
.progress.warn span { background: var(--warn); } .progress.danger span { background: var(--danger); }
.wear { margin-top: .75rem; }
.code-input { font-family: var(--mono); font-size: 1.3rem; letter-spacing: .2em; text-align: center; }
.codes { columns: 2; list-style: none; padding: 0; font-family: var(--mono); font-size: 1.05rem; }
.codes li { padding: .2rem 0; }
.totp-setup { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-start; }
.totp-setup .qr svg { display: block; border-radius: 8px; border: 1px solid var(--border); max-width: 100%; height: auto; }
.totp-setup .qr { flex: 0 0 auto; max-width: 240px; }
.totp-setup > div:last-child { flex: 1 1 260px; }
code.secret { display: inline-block; margin-top: .3rem; padding: .3rem .5rem; background: var(--surface-2); border-radius: 6px; font-size: 1rem; letter-spacing: .05em; word-break: break-all; }
table.dope td, table.dope th { padding: .35rem .6rem; }
.report { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.report h1 { font-size: 1.35rem; } .report h2 { font-size: 1.1rem; margin-top: 1.5rem; border-bottom: 2px solid var(--primary); padding-bottom: .3rem; }
.report-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.report-head p { margin: .25rem 0; }
.report-total { text-align: right; } .report-total span { display: block; color: var(--muted); font-size: .8rem; } .report-total strong { font-size: 1.4rem; }
.report-item { display: flex; gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--border); break-inside: avoid; }
.report-item img { width: 150px; height: 110px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); flex: 0 0 auto; }
.report-item > div { flex: 1; min-width: 0; }
.report-item h3 { margin: 0 0 .4rem; }
table.kv { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.kv th { text-align: left; color: var(--muted); font-weight: 500; padding: .15rem .6rem .15rem 0; white-space: nowrap; width: 1%; }
table.kv td { padding: .15rem 1rem .15rem 0; }
.report-sub { text-align: right; }
.report-foot { margin-top: 2rem; font-size: .8rem; color: var(--muted); }
.report-foot .sign { display: flex; gap: 3rem; margin-top: 2rem; } .report-foot .sign span { flex: 1; border-top: 1px solid var(--muted); padding-top: .3rem; }
.dope-card { max-width: 640px; }
.dope-card header p { margin: .2rem 0; }
.dope-card footer { margin-top: 1rem; }
@media (max-width: 760px) {
  .report { padding: 1rem; }
  .report-item { flex-direction: column; }
  .report table.compact, .card table.compact { display: block; overflow-x: auto; max-width: 100%; }
  .spec-form > * { max-width: 100%; }
  .report-item img { width: 100%; height: 180px; }
  table.kv, table.kv tbody, table.kv tr { display: block; }
  table.kv th, table.kv td { display: inline-block; width: 50%; vertical-align: top; }
}

/* ---------- Bouton flottant (mobile) ---------- */
.fab { display: none; }

/* ======================= Tablette ======================= */
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .sidenav { width: 64px; }
  .sidenav a span { display: none; }
  .sidenav a { justify-content: center; padding: .7rem; }
}

/* ======================= Mobile ======================= */
@media (max-width: 760px) {
  body { font-size: 15px; }
  .nav-toggle { display: block; }
  .usernav a, .usernav form { display: none; }
  .usernav .link-btn { font-size: .85rem; }
  .shell { display: block; }
  .sidenav { position: fixed; top: 0; left: 0; bottom: 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .22s ease; padding-top: calc(3.6rem + env(safe-area-inset-top)); overflow-y: auto; visibility: hidden; }
  .sidenav ul { position: static; }
  body.nav-open .sidenav { transform: none; visibility: visible; box-shadow: 4px 0 20px rgba(0,0,0,.25); }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  .sidenav a span { display: inline; }
  .sidenav a { justify-content: flex-start; padding: .75rem .9rem; font-size: 1rem; }
  .only-mobile { display: block; }
  .nav-sep { display: block; border-top: 1px solid rgba(255,255,255,.1); margin: .5rem 0; }
  .topbar { z-index: 45; }
  .main { padding: 1rem 1rem 6rem; }
  .main.solo { padding-top: 1.5rem; }
  h1 { font-size: 1.25rem; }
  .card { padding: .95rem 1rem; border-radius: 12px; }
  .card:not(.flush) > .table:not(.compact) { margin: 0 -1rem; width: calc(100% + 2rem); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .kpi { padding: .7rem .8rem; }
  .kpi-v { font-size: 1.4rem; }
  .page-head { flex-direction: column; }
  .page-actions { width: 100%; }
  .filters input[type=search] { width: 100%; }
  .field.w-m { width: 100%; }
  .field.w-s { width: calc(50% - .5rem); }
  .field.w-xs { width: calc(33% - .5rem); min-width: 6.5rem; }

  /* Tableaux -> cartes empilées */
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { padding: .6rem 1rem; border-bottom: 1px solid var(--border); }
  .table.responsive td { border: 0; padding: .12rem 0; text-align: left !important; display: flex; gap: .75rem; }
  .table.responsive td[data-label]::before { content: attr(data-label); flex: 0 0 38%; color: var(--muted); font-size: .8rem; padding-top: .1rem; }
  .table.responsive td:first-child { font-size: 1rem; padding-bottom: .25rem; }
  .table.responsive td:first-child::before { display: none; }
  .table.responsive td:first-child > * { flex: none; }
  .table.responsive td:first-child { flex-wrap: wrap; column-gap: .4rem; }
  .table.responsive td:empty, .table.responsive td[data-label]:not(:has(*)):empty { display: none; }
  .table.responsive td.row-actions { justify-content: flex-start; padding-top: .4rem; flex-wrap: wrap; gap: .4rem; }
  .table.responsive tfoot { display: table; width: 100%; }
  .card.flush { border-radius: 12px; }

  .fab { display: flex; position: fixed; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); font-size: 1.9rem; font-weight: 300; align-items: center; justify-content: center; box-shadow: 0 4px 14px rgba(0,0,0,.3); z-index: 20; }
  .fab:hover { text-decoration: none; }
  body.has-sticky-actions .fab { display: none; }
  .line { padding: .75rem 2.4rem .75rem .75rem; }
  .line .field.w-m { width: 100%; }
  .acc-picker { grid-template-columns: 1fr; }
}
@media print {
  .topbar, .sidenav, .fab, .page-actions, .filters, .add-block, .foot, .actions, .no-print, .flash, .spec-form, .row-actions { display: none !important; }
  :root { --text: #000; --muted: #555; --surface: #fff; --surface-2: #f2f2f2; --border: #bbb; --primary: #2f5d46; }
  body { background: #fff; color: #000; font-size: 11pt; } .main { padding: 0; max-width: none; }
  .card, .report { box-shadow: none; border: 0; padding: 0; break-inside: avoid; }
  .report-item img { width: 120px; height: 90px; }
  a { color: inherit; text-decoration: none; }
  @page { margin: 14mm; }
}
.quick-actions { margin: .5rem 0 .75rem; }
.tabs.views { margin-bottom: .4rem; }
.tabs.years { border-bottom: 0; margin-bottom: 1rem; }
.tabs.years a { padding: .3rem .7rem; font-size: .84rem; border-bottom: 0; border-radius: 99px; }
.tabs.years a.active { background: var(--primary-soft); color: var(--primary); }
@media (max-width: 760px) {
  .table.responsive.foot-wrap tfoot { display: none; } /* totaux déjà affichés en tête (KPI) */
}

/* ---------- Grilles triables / filtrables (grid.js) ---------- */
.table tr[hidden] { display: none !important; }
.grid-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.grid-scroll.bleed { margin: 0 -1.2rem; max-width: none; }
.grid-scroll > .table { width: 100%; margin: 0; }
.grid-toolbar { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; margin: 0 0 .6rem; }
.grid-toolbar input[type=search] { width: 16rem; min-height: 34px; padding: .3rem .6rem; font-size: .9rem; }
.card > .grid-toolbar { margin-top: -.25rem; }
.grid-count { margin-left: auto; }
.grid-sort-mobile { display: none; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--text); }
th.sortable::after { content: "↕"; margin-left: .3rem; opacity: .3; font-size: .9em; }
th.sort-asc::after { content: "▲"; opacity: .9; color: var(--primary); }
th.sort-desc::after { content: "▼"; opacity: .9; color: var(--primary); }
th.sortable:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
tr.grid-filters th { padding: .3rem .4rem; background: var(--surface); text-transform: none; letter-spacing: 0; }
tr.grid-filters input, tr.grid-filters select { min-height: 30px; padding: .2rem .4rem; font-size: .8rem; width: 100%; min-width: 4.5rem; border-radius: 6px; }
tr.grid-empty td { text-align: center; color: var(--muted); padding: 1.2rem; }
tfoot.grid-foot-stale th { opacity: .45; }
tfoot.grid-foot-stale th:first-child::after { content: " (non filtré)"; font-weight: 400; text-transform: none; }
@media (max-width: 760px) {
  .grid-toolbar input[type=search] { width: 100%; }
  .grid-sort-mobile { display: inline-flex; }
  select.grid-sort-mobile { width: auto; flex: 1 1 8rem; min-height: 34px; padding: .25rem .5rem; font-size: .9rem; }
  .grid-count { margin-left: 0; }
  .grid-scroll.bleed { margin: 0 -1rem; }
  .table.responsive tr.grid-empty td::before { display: none; }
}
@media print { .grid-toolbar, tr.grid-filters { display: none !important; } }
.btn.icon { min-width: 32px; padding: .3rem .5rem; font-size: .95rem; }
@media (min-width: 1101px) { .grid-2.refs-layout { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }
.grid-toolbar [hidden] { display: none !important; }

/* ---------- Téléversement multiple & classement ---------- */
.dropzone { display: flex; flex-direction: column; align-items: center; gap: .3rem; text-align: center; padding: 1.4rem 1rem; border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dz-title { font-weight: 600; }
.dz-help { font-size: .8rem; color: var(--muted); max-width: 36rem; }
.dz-list { list-style: none; padding: 0; margin: .4rem 0 0; font-size: .85rem; text-align: left; max-height: 12rem; overflow: auto; width: 100%; max-width: 36rem; }
.dz-list li { padding: .15rem 0; border-bottom: 1px dashed var(--border); }
.dropzone.has-files { border-style: solid; border-color: var(--primary); }
.upload-form .actions { margin-top: .75rem; }
th.sel, td.sel { width: 2.2rem; text-align: center !important; }
.bulk-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .6rem; }
.bulk-bar.active { padding: .4rem .6rem; background: var(--primary-soft); border-radius: 8px; }
.doc-item { display: flex; gap: 1rem; align-items: flex-start; }
.doc-item.to-delete { opacity: .5; border-color: var(--danger); }
.doc-prev { flex: 0 0 110px; width: 110px; height: 110px; border-radius: 8px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; }
.doc-prev img { width: 100%; height: 100%; object-fit: cover; }
.ficon.big { font-size: 1rem; padding: .5rem .7rem; }
.doc-fields { flex: 1; min-width: 0; }
.doc-fields > p { margin: 0 0 .5rem; }
.danger-text { color: var(--danger) !important; }
.apply-all { border-color: var(--primary); }
@media (max-width: 760px) {
  .doc-item { flex-direction: column; }
  .doc-prev { width: 100%; height: 160px; flex-basis: auto; }
  .table.responsive td.sel { justify-content: flex-start; }
}
.bulk-item { padding-top: .8rem; padding-bottom: .5rem; }
.bulk-item.has-errors { border-color: var(--danger); }
.bulk-item .fields { gap: .6rem .9rem; }
.bulk-item p { margin: .4rem 0 0; }
.add-block > summary.btn { white-space: normal; text-align: left; }
.sel-all-mobile { display: none; }
@media (max-width: 760px) {
  .sel-all-mobile { display: inline-flex; }
  .table.responsive tr { position: relative; }
  .table.responsive td.sel { position: absolute; top: .55rem; right: .8rem; width: auto; padding: 0; z-index: 1; }
  .table.responsive td.sel + td { font-size: 1rem; padding-bottom: .25rem; padding-right: 2rem; flex-wrap: wrap; column-gap: .4rem; }
  .table.responsive td.sel + td::before { display: none; }
  .table.responsive td.sel + td > * { flex: none; }
}
.zero-last { display: flex; gap: 1.2rem; align-items: center; padding: .6rem .8rem; margin-bottom: .8rem; background: var(--primary-soft); border-radius: 8px; }
.zero-last .kpi-v { display: block; font-size: 1.5rem; }
.zero-last .kpi-l { display: block; }
.zero-last .kpi-v { white-space: nowrap; }
.dup-group { display: inline-flex; align-items: center; gap: .3rem; }
.dup-group input.copies { width: 3.6rem; min-height: 30px; padding: .2rem .35rem; font-size: .85rem; }

/* ---------- v1.7 : application iPhone (PWA) & mode stand ---------- */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px; }
.offline-banner { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(5rem + env(safe-area-inset-bottom)); z-index: 60; background: var(--nav-bg); color: var(--nav-ink); padding: .5rem .9rem; border-radius: 99px; font-size: .85rem; box-shadow: 0 4px 14px rgba(0,0,0,.3); white-space: nowrap; }
.offline-banner a { color: #fff; text-decoration: underline; }
.install-hint .ios-share { display: inline-block; width: 14px; height: 17px; vertical-align: -2px; border: 2px solid currentColor; border-top: 0; border-radius: 0 0 3px 3px; position: relative; margin: 0 2px; }
.install-hint .ios-share::before { content: ""; position: absolute; left: 50%; top: -7px; width: 2px; height: 12px; background: currentColor; transform: translateX(-50%); }
.passkey-box { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); text-align: center; }
.passkey-box .btn { gap: .5rem; }
.faceid { width: 20px; height: 20px; }
.geo-btn { margin-top: .35rem; }
.mt { margin-top: .4rem; }
.warn-text { color: var(--warn); }

.stand-status { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .5rem; margin-bottom: .75rem; }
.stand-status .grow { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 700; padding: .15rem .6rem; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.pill.off { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.pill.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.stand-tabs a { font-size: .95rem; }
.btn.big { min-height: 56px; font-size: 1.1rem; margin-bottom: .6rem; }
.stand-start .btn.block + .btn.block { margin-top: .2rem; }
.stand-line { position: relative; padding-right: 2.6rem; }
.stand-line .fields { margin-bottom: .4rem; }
.counter { margin: .3rem 0 .6rem; }
.counter > label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: .25rem; }
.counter-row { display: flex; gap: .4rem; align-items: stretch; }
.counter-row .btn { min-width: 52px; min-height: 52px; font-size: 1.05rem; padding: .3rem .5rem; flex: 0 0 auto; touch-action: manipulation; }
.counter-row input { flex: 1; min-width: 4rem; text-align: center; font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; min-height: 52px; }
.counter .help.error { color: var(--danger); }
button.chip { border: 1px solid transparent; font: inherit; font-size: .85rem; padding: .3rem .7rem; cursor: pointer; min-height: 32px; touch-action: manipulation; }
button.chip.on { background: var(--primary); color: var(--primary-ink); }
.stand-line .chips { align-self: flex-end; margin: 0; }
.addon-btn { border-radius: 0 8px 8px 0; border-left: 0; min-height: 0; padding: 0 .7rem; }
.input-group select:first-child { border-radius: 8px 0 0 8px; flex: 1; min-width: 0; }
.stand-photos { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.stand-photos figure { position: relative; margin: 0; }
.stand-photos img { width: 92px; height: 92px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); display: block; }
.stand-photos .line-del { top: -8px; right: -8px; }
.photo-btn { min-height: 92px; min-width: 92px; flex-direction: column; border-style: dashed; }
.stand-actions { display: flex; gap: .5rem; }
.stand-actions .btn.primary { flex: 1; min-height: 50px; font-size: 1.05rem; }
.queue { list-style: none; margin: 0; padding: 0; }
.queue li { padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
.queue li:last-child { border-bottom: 0; }
.queue .q-actions { display: flex; gap: .4rem; margin-top: .4rem; flex-wrap: wrap; }
.queue ul { margin: .3rem 0 0 1rem; padding: 0; }
.dope-table td.big-num { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.dope-table tr.group td { background: var(--surface-2); font-weight: 600; font-size: .82rem; color: var(--muted); }
.cred-list { list-style: none; margin: .5rem 0 1rem; padding: 0; }
.cred-list li { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.cred-list li .grow { flex: 1; min-width: 12rem; }
body.is-standalone .foot { padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
@media (max-width: 760px) {
  .stand .card { padding: .85rem; }
  .stand-line .field.w-l, .stand-line .field.w-m { width: 100%; }
  .stand-actions { background: var(--bg); }
  body[data-page="stand"] .main { padding-bottom: 2rem; }
}
@media print { .offline-banner, .install-hint { display: none !important; } }
.only-mobile .nav-logout { display: block; width: 100%; text-align: left; background: none; border: 0; font: inherit; font-size: 1rem; color: var(--nav-ink); padding: .75rem .9rem; border-radius: 8px; cursor: pointer; }
.dope-table th:last-child, .dope-table td:last-child { padding-right: 1rem; }
