/* =========================================================================
   CIBLE — feuille de style unique
   Charte strictement noir & blanc. Les statuts sont differencies par la
   forme (plein / contour / trame), jamais par la couleur.
   ========================================================================= */

:root {
  --bg: #f4f4f4;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #ededed;
  --ink: #0a0a0a;
  --ink-2: #3d3d3d;
  --muted: #757575;
  --line: #d9d9d9;
  --line-strong: #b3b3b3;
  --invert-bg: #0a0a0a;
  --invert-ink: #ffffff;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.06);
  --shadow-lg: 0 12px 48px rgba(0,0,0,.18);
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-w: 248px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --hatch: repeating-linear-gradient(45deg, transparent 0 3px, rgba(0,0,0,.14) 3px 5px);
}

html[data-theme="dark"] {
  --bg: #0b0b0b;
  --surface: #151515;
  --surface-2: #1b1b1b;
  --surface-3: #232323;
  --ink: #f5f5f5;
  --ink-2: #cfcfcf;
  --muted: #8e8e8e;
  --line: #2e2e2e;
  --line-strong: #454545;
  --invert-bg: #f5f5f5;
  --invert-ink: #0a0a0a;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 8px 24px rgba(0,0,0,.45);
  --shadow-lg: 0 12px 48px rgba(0,0,0,.7);
  --hatch: repeating-linear-gradient(45deg, transparent 0 3px, rgba(255,255,255,.16) 3px 5px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
img { max-width: 100%; }

::selection { background: var(--ink); color: var(--surface); }

/* ----------------------------- Ecran de boot ---------------------------- */
.boot {
  min-height: 100vh; display: grid; place-content: center; justify-items: center;
  gap: 1rem; color: var(--muted);
}
.boot-logo { width: 56px; height: 56px; color: var(--ink); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity:.35; transform: scale(.94);} 50% { opacity:1; transform: scale(1);} }

/* ------------------------------ Connexion ------------------------------- */
.login-screen {
  min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr;
}
.login-aside {
  background: var(--invert-bg); color: var(--invert-ink);
  padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-aside::after {
  content: ""; position: absolute; right: -140px; bottom: -140px;
  width: 460px; height: 460px; border-radius: 50%;
  border: 40px solid currentColor; opacity: .10;
  box-shadow: inset 0 0 0 40px transparent;
}
.login-aside::before {
  content: ""; position: absolute; right: -40px; bottom: -40px;
  width: 260px; height: 260px; border-radius: 50%;
  border: 34px solid currentColor; opacity: .12;
}
.login-brand { display: flex; align-items: center; gap: .8rem; font-size: 1.6rem; font-weight: 800; letter-spacing: .22em; }
.login-brand img { width: 38px; height: 38px; }
.login-baseline { max-width: 26rem; }
.login-baseline h1 { font-size: 2.1rem; line-height: 1.15; margin: 0 0 .8rem; letter-spacing: -.02em; }
.login-baseline p { opacity: .75; margin: 0; }
.login-points { display: grid; gap: .5rem; margin-top: 1.6rem; padding: 0; list-style: none; opacity: .8; font-size: .9rem; }
.login-points li { display: flex; gap: .6rem; align-items: baseline; }
.login-points li::before { content: "—"; opacity: .5; }
.login-foot { font-size: .78rem; opacity: .55; }

.login-main { display: grid; place-content: center; padding: 2rem; }
.login-card { width: min(400px, 92vw); }
.login-card h2 { margin: 0 0 .35rem; font-size: 1.4rem; letter-spacing: -.01em; }
.login-card > p.sub { margin: 0 0 1.6rem; color: var(--muted); font-size: .9rem; }
.login-hint {
  margin-top: 1.4rem; padding: .85rem 1rem; border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm); font-size: .8rem; color: var(--muted); background: var(--surface-2);
}
.login-hint code { font-family: var(--mono); color: var(--ink); }

@media (max-width: 900px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-aside { display: none; }
}

/* ------------------------------- Structure ------------------------------ */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-head {
  display: flex; align-items: center; gap: .7rem; padding: 1.15rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.sidebar-head img { width: 30px; height: 30px; }
.sidebar-head .name { font-weight: 800; letter-spacing: .2em; font-size: 1.02rem; }
.sidebar-head .org { font-size: .68rem; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }

.nav { padding: .8rem .7rem; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-label {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .13em; color: var(--muted);
  padding: 1rem .6rem .35rem;
}
.nav a {
  display: flex; align-items: center; gap: .65rem; padding: .55rem .65rem;
  border-radius: var(--radius-sm); text-decoration: none; color: var(--ink-2);
  font-size: .9rem; font-weight: 500; border: 1px solid transparent; transition: background .12s, color .12s;
}
.nav a:hover { background: var(--surface-3); color: var(--ink); }
.nav a.active { background: var(--invert-bg); color: var(--invert-ink); font-weight: 600; }
.nav a .ico { width: 17px; height: 17px; flex: none; }
.nav a .count {
  margin-left: auto; font-family: var(--mono); font-size: .72rem;
  background: var(--surface-3); color: var(--ink-2); padding: .05rem .38rem; border-radius: 20px;
}
.nav a.active .count { background: rgba(255,255,255,.22); color: var(--invert-ink); }
html[data-theme="dark"] .nav a.active .count { background: rgba(0,0,0,.2); }

.sidebar-foot { border-top: 1px solid var(--line); padding: .8rem; }
.user-chip { display: flex; align-items: center; gap: .65rem; width: 100%; }
.avatar {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  background: var(--invert-bg); color: var(--invert-ink);
  display: grid; place-content: center; font-weight: 700; font-size: .76rem; letter-spacing: .02em;
}
.user-chip .meta { min-width: 0; }
.user-chip .meta strong { display: block; font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .meta span { font-size: .7rem; color: var(--muted); }

/* ------------------------------- Topbar --------------------------------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; background: var(--bg);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 1rem; padding: .85rem 1.6rem;
}
.topbar h1 { margin: 0; font-size: 1.18rem; letter-spacing: -.01em; }
.topbar .crumb { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.topbar .spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.page { padding: 1.5rem 1.6rem 4rem; max-width: 1500px; width: 100%; }
.page-intro { color: var(--muted); font-size: .88rem; margin: -.4rem 0 1.2rem; max-width: 70ch; }

@media (max-width: 940px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; transform: translateX(-100%); transition: transform .2s; width: var(--sidebar-w); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .page { padding: 1rem; }
  .topbar { padding: .7rem 1rem; }
}
.burger { display: none; }
@media (max-width: 940px) { .burger { display: inline-flex; } }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; row-gap: .55rem; }
  .topbar h1 { font-size: 1.02rem; }
  /* Les actions défilent horizontalement plutôt que d'être compressées */
  .topbar-actions {
    order: 3; width: 100%; flex-wrap: nowrap; overflow-x: auto;
    scrollbar-width: none; -ms-overflow-style: none;
    margin: 0 -.2rem; padding: 0 .2rem .15rem;
  }
  .topbar-actions::-webkit-scrollbar { display: none; }
  .topbar-actions .btn, .topbar-actions select, .topbar-actions a { flex: 0 0 auto; white-space: nowrap; }
  .kpi .value { font-size: 1.7rem; }
  .modal-foot { flex-wrap: wrap; }
  .stat-inline { gap: .9rem; }
}

/* ------------------------------- Boutons -------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .48rem .85rem; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: inherit; font-size: .85rem; font-weight: 550;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-3); border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible {
  outline: 2px solid var(--ink); outline-offset: 2px;
}
.btn.primary { background: var(--invert-bg); color: var(--invert-ink); border-color: var(--invert-bg); }
.btn.primary:hover { opacity: .87; background: var(--invert-bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.danger { border-color: var(--ink); }
.btn.danger:hover { background: var(--invert-bg); color: var(--invert-ink); }
.btn.sm { padding: .28rem .55rem; font-size: .78rem; }
.btn.icon { padding: .42rem; }
.btn .ico { width: 16px; height: 16px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.btn-group { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.btn-group .btn { border: 0; border-radius: 0; border-right: 1px solid var(--line); }
.btn-group .btn:last-child { border-right: 0; }
.btn-group .btn.on { background: var(--invert-bg); color: var(--invert-ink); }

/* -------------------------------- Cartes -------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
}
.card.tight { padding: 0; overflow: hidden; }
.card-head {
  display: flex; align-items: center; gap: .8rem; margin-bottom: .9rem;
}
.card-head h3 { margin: 0; font-size: .95rem; letter-spacing: -.01em; }
.card-head .sub { font-size: .76rem; color: var(--muted); }
.card-head .spacer { flex: 1; }
.card.tight .card-head { padding: 1rem 1.2rem 0; margin-bottom: .6rem; }

.grid { display: grid; gap: 1rem; }
.grid.k4 { grid-template-columns: repeat(4, 1fr); }
.grid.k3 { grid-template-columns: repeat(3, 1fr); }
.grid.k2 { grid-template-columns: repeat(2, 1fr); }
.grid.a2 { grid-template-columns: 2fr 1fr; }
.grid.a3 { grid-template-columns: 1.5fr 1fr; }
@media (max-width: 1200px) { .grid.k4 { grid-template-columns: repeat(2, 1fr); } .grid.a2, .grid.a3 { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .grid.k4, .grid.k3, .grid.k2 { grid-template-columns: 1fr; } }

/* --------------------------------- KPI ---------------------------------- */
.kpi { position: relative; overflow: hidden; }
.kpi .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.kpi .value { font-size: 2rem; font-weight: 750; letter-spacing: -.03em; font-family: var(--mono); line-height: 1.15; margin-top: .3rem; }
.kpi .value small { font-size: .95rem; font-weight: 500; color: var(--muted); font-family: var(--font); }
.kpi .foot { font-size: .76rem; color: var(--muted); margin-top: .35rem; }
.kpi .ico-bg { position: absolute; right: -12px; top: -12px; width: 92px; height: 92px; opacity: .05; }
.kpi.invert { background: var(--invert-bg); color: var(--invert-ink); border-color: var(--invert-bg); }
.kpi.invert .label, .kpi.invert .foot { color: rgba(255,255,255,.65); }
html[data-theme="dark"] .kpi.invert .label, html[data-theme="dark"] .kpi.invert .foot { color: rgba(0,0,0,.6); }

/* -------------------------------- Badges -------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 600;
  padding: .16rem .5rem; border-radius: 20px; border: 1px solid var(--line-strong); white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid currentColor; }
.badge.solid { background: var(--invert-bg); color: var(--invert-ink); border-color: var(--invert-bg); }
.badge.solid .dot { background: currentColor; }
.badge.outline .dot { background: transparent; }
.badge.hatch { background-image: var(--hatch); }
.badge.hatch .dot { background: currentColor; opacity: .5; }
.badge.muted { color: var(--muted); border-color: var(--line); }
.badge.muted .dot { border-style: dashed; }

/* Statuts de conformite */
.st-CONFORME { background: var(--invert-bg); color: var(--invert-ink); border-color: var(--invert-bg); }
.st-CONFORME .dot { background: currentColor; }
.st-EN_COURS { border-color: var(--line-strong); }
.st-EN_COURS .dot { background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
.st-ALERTE { background-image: var(--hatch); border-color: var(--ink); font-weight: 700; }
.st-ALERTE .dot { background: currentColor; }
.st-CRITIQUE { background: var(--invert-bg); color: var(--invert-ink); border-color: var(--invert-bg); font-weight: 700; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--ink); }
.st-CRITIQUE .dot { background: currentColor; animation: blink 1.6s steps(2,end) infinite; }
.st-NON_CONCERNE { color: var(--muted); border-style: dashed; }
@keyframes blink { 50% { opacity: .25; } }

/* -------------------------------- Tables -------------------------------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .855rem; }
table.data th {
  text-align: left; font-size: .68rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted); font-weight: 700; padding: .6rem .75rem; border-bottom: 1px solid var(--line-strong);
  white-space: nowrap; background: var(--surface); position: sticky; top: 0; z-index: 1;
}
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--ink); }
table.data th .arrow { opacity: .45; font-size: .8em; }
table.data td { padding: .6rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr.clickable { cursor: pointer; }
table.data td.num, table.data th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.data .strong { font-weight: 650; }
table.data .dim { color: var(--muted); font-size: .82em; }
table.data tr.inactive td { opacity: .5; }
.empty { padding: 2.6rem 1rem; text-align: center; color: var(--muted); font-size: .88rem; }
.empty strong { display: block; color: var(--ink); margin-bottom: .3rem; font-size: .95rem; }

/* ------------------------------ Progression ----------------------------- */
.bar { height: 7px; background: var(--surface-3); border-radius: 20px; overflow: hidden; min-width: 72px; }
.bar > i { display: block; height: 100%; background: var(--ink); border-radius: 20px; transition: width .4s; }
.bar.partial > i { background-image: var(--hatch); }
.progress-cell { display: flex; align-items: center; gap: .5rem; }
.progress-cell .txt { font-family: var(--mono); font-size: .78rem; color: var(--muted); white-space: nowrap; }

/* ------------------------------ Formulaires ----------------------------- */
.field { display: block; margin-bottom: .85rem; }
.field > label { display: block; font-size: .76rem; font-weight: 650; margin-bottom: .3rem; letter-spacing: .01em; }
.field > label .req { color: var(--muted); font-weight: 400; }
.field input, .field select, .field textarea {
  width: 100%; padding: .5rem .65rem; font: inherit; font-size: .87rem;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
.field textarea { min-height: 76px; resize: vertical; }
.field .help { font-size: .74rem; color: var(--muted); margin-top: .25rem; }
.field-row { display: grid; gap: .85rem; grid-template-columns: repeat(2, 1fr); }
.field-row.k3 { grid-template-columns: repeat(3, 1fr); }
.field-row.k4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 700px) { .field-row, .field-row.k3, .field-row.k4 { grid-template-columns: 1fr; } }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .9rem 1rem; margin: 0 0 1rem; }
legend { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: 0 .35rem; }

.checks { display: flex; flex-wrap: wrap; gap: .45rem; }
.check {
  display: inline-flex; align-items: center; gap: .4rem; padding: .32rem .6rem;
  border: 1px solid var(--line-strong); border-radius: 20px; font-size: .8rem; cursor: pointer; user-select: none;
}
.check input { accent-color: var(--ink); margin: 0; }
.check:has(input:checked) { background: var(--invert-bg); color: var(--invert-ink); border-color: var(--invert-bg); }

.search {
  display: flex; align-items: center; gap: .45rem; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: .3rem .6rem;
}
.search input { border: 0; background: transparent; font: inherit; font-size: .85rem; color: var(--ink); padding: .2rem 0; width: 220px; }
.search input:focus { outline: none; }
.search .ico { width: 15px; height: 15px; opacity: .5; }

.toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .spacer { flex: 1; }
select.inline { padding: .4rem .55rem; font: inherit; font-size: .84rem; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }

/* -------------------------------- Modale -------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(2px);
  display: grid; place-items: center; z-index: 100; padding: 1.5rem; overflow-y: auto;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  width: min(760px, 100%); max-height: calc(100vh - 3rem); display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: rise .18s ease;
}
.modal.wide { width: min(1080px, 100%); }
.modal.narrow { width: min(460px, 100%); }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.modal-head { display: flex; align-items: center; gap: .8rem; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 1.02rem; }
.modal-head .sub { font-size: .76rem; color: var(--muted); }
.modal-head .spacer { flex: 1; }
.modal-body { padding: 1.2rem; overflow-y: auto; }
.modal-foot { display: flex; gap: .6rem; justify-content: flex-end; padding: .9rem 1.2rem; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.modal-foot .spacer { flex: 1; }

/* -------------------------------- Toasts -------------------------------- */
.toast-root { position: fixed; right: 1.1rem; bottom: 1.1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 200; }
.toast {
  background: var(--invert-bg); color: var(--invert-ink); padding: .65rem .95rem;
  border-radius: var(--radius-sm); font-size: .85rem; box-shadow: var(--shadow-lg);
  max-width: 380px; display: flex; gap: .55rem; align-items: flex-start; animation: rise .18s ease;
}
.toast.err { border: 2px solid var(--invert-ink); }
.toast .ico { width: 16px; height: 16px; flex: none; margin-top: 1px; }

/* ------------------------------ Graphiques ------------------------------ */
.chart { width: 100%; overflow: visible; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.chart .bar-fill { fill: var(--ink); }
.chart .bar-fill.alt { fill: var(--muted); }
.chart .label { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.chart .value-label { fill: var(--ink); font-size: 10px; font-family: var(--mono); font-weight: 600; }
.chart .line { fill: none; stroke: var(--ink); stroke-width: 2; }
.chart .point { fill: var(--surface); stroke: var(--ink); stroke-width: 2; }

.donut-wrap { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.donut { flex: none; }
.donut-legend { display: grid; gap: .4rem; font-size: .82rem; flex: 1; min-width: 160px; }
.donut-legend div { display: flex; align-items: center; gap: .5rem; }
.donut-legend .swatch { width: 12px; height: 12px; border: 1px solid var(--ink); flex: none; }
.donut-legend .n { margin-left: auto; font-family: var(--mono); font-weight: 600; }

/* ------------------------------- Alertes -------------------------------- */
.alert-list { display: flex; flex-direction: column; }
.alert-item {
  display: flex; gap: .8rem; padding: .75rem 0; border-bottom: 1px solid var(--line); align-items: flex-start;
}
.alert-item:last-child { border-bottom: 0; }
.alert-mark {
  width: 26px; height: 26px; flex: none; border-radius: 50%; border: 2px solid var(--ink);
  display: grid; place-content: center; font-size: .8rem; font-weight: 800;
}
.alert-item.critique .alert-mark { background: var(--invert-bg); color: var(--invert-ink); }
.alert-item.avertissement .alert-mark { background-image: var(--hatch); }
.alert-item.info .alert-mark { border-style: dashed; color: var(--muted); }
.alert-body { min-width: 0; flex: 1; }
.alert-body strong { display: block; font-size: .87rem; }
.alert-body p { margin: .12rem 0 0; font-size: .82rem; color: var(--ink-2); }
.alert-body .action { font-size: .74rem; color: var(--muted); margin-top: .2rem; display: block; }
.alert-type { font-size: .64rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

/* ------------------------------ Cartes armes ---------------------------- */
.weapon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.weapon-card { display: flex; flex-direction: column; gap: .6rem; cursor: pointer; transition: border-color .12s, transform .1s; }
.weapon-card:hover { border-color: var(--ink); transform: translateY(-2px); }
.weapon-visual {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  height: 96px; display: grid; place-items: center; padding: .5rem; position: relative;
}
.weapon-visual img { width: 88%; height: auto; max-height: 76px; object-fit: contain; }
.weapon-visual .cat-tag {
  position: absolute; top: .4rem; left: .5rem; font-size: .62rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
.weapon-card h4 { margin: 0; font-size: .95rem; }
.weapon-card .serial { font-family: var(--mono); font-size: .76rem; color: var(--muted); }
.weapon-card .rows { display: grid; gap: .22rem; font-size: .8rem; }
.weapon-card .rows div { display: flex; justify-content: space-between; gap: .5rem; }
.weapon-card .rows span:first-child { color: var(--muted); }
.weapon-thumb { width: 46px; height: 26px; object-fit: contain; }

/* --------------------------- Fiche / detail ----------------------------- */
.detail-head { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.detail-head .avatar { width: 52px; height: 52px; font-size: 1rem; }
.detail-head h2 { margin: 0; font-size: 1.3rem; }
.detail-head .meta { color: var(--muted); font-size: .85rem; }
.deflist { display: grid; grid-template-columns: auto 1fr; gap: .35rem .9rem; font-size: .85rem; align-items: baseline; }
.deflist dt { color: var(--muted); }
.deflist dd { margin: 0; font-weight: 550; }

.timeline { position: relative; padding-left: 1.3rem; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.timeline-item { position: relative; padding: 0 0 1rem; }
.timeline-item::before {
  content: ""; position: absolute; left: -1.3rem; top: 5px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--ink);
}
.timeline-item.dim::before { border-color: var(--line-strong); }
.timeline-item .when { font-size: .72rem; color: var(--muted); font-family: var(--mono); }
.timeline-item .what { font-size: .87rem; font-weight: 550; }
.timeline-item .who { font-size: .78rem; color: var(--muted); }

/* Cible decorative / score */
.score-ring { display: inline-grid; place-items: center; position: relative; }
.score-ring .txt { position: absolute; font-family: var(--mono); font-weight: 700; font-size: .9rem; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.1rem; flex-wrap: wrap; }
.tabs button {
  border: 0; background: transparent; font: inherit; font-size: .87rem; font-weight: 550; color: var(--muted);
  padding: .55rem .8rem; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--ink); }

.chips { display: flex; gap: .35rem; flex-wrap: wrap; }
.chip {
  font-size: .72rem; padding: .12rem .45rem; border: 1px solid var(--line-strong);
  border-radius: 4px; font-family: var(--mono); letter-spacing: .02em;
}

.stat-inline { display: flex; gap: 1.4rem; flex-wrap: wrap; }
.stat-inline > div .k { font-size: .7rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.stat-inline > div .v { font-size: 1.25rem; font-weight: 700; font-family: var(--mono); }

hr.sep { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 1rem; }
.mb0 { margin-bottom: 0; }

/* Participants (saisie de seance) */
.participant-row {
  display: grid; grid-template-columns: 1.6fr 1.6fr .7fr .7fr .9fr auto; gap: .5rem;
  align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--line);
}
.participant-row select, .participant-row input {
  width: 100%; padding: .35rem .45rem; font: inherit; font-size: .8rem; background: var(--surface-2);
  color: var(--ink); border: 1px solid var(--line-strong); border-radius: 4px;
}
.participant-head { font-size: .66rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
@media (max-width: 900px) { .participant-row { grid-template-columns: 1fr 1fr; } .participant-head { display: none; } }

.picker-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.picker-item { display: flex; align-items: center; gap: .6rem; padding: .45rem .7rem; border-bottom: 1px solid var(--line); font-size: .85rem; cursor: pointer; }
.picker-item:last-child { border-bottom: 0; }
.picker-item:hover { background: var(--surface-2); }
.picker-item input { accent-color: var(--ink); }

/* =========================================================================
   VERSION MOBILE — application installable (PWA)
   ========================================================================= */

/* Barre d'onglets fixe en bas d'écran */
.tabbar { display: none; }
.offline-bar { display: none; }

@media (max-width: 900px) {
  .tabbar {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
    background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -1px 12px rgba(0,0,0,.06);
  }
  html[data-theme="dark"] .tabbar { box-shadow: 0 -1px 12px rgba(0,0,0,.5); }
  .tabbar a, .tabbar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; padding: .5rem .2rem .45rem; min-height: 54px;
    font: inherit; font-size: .64rem; font-weight: 600; letter-spacing: .01em;
    color: var(--muted); text-decoration: none; background: none; border: 0; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .tabbar a.active { color: var(--ink); }
  .tabbar a.active .ico { transform: translateY(-1px); }
  .tabbar .ico { width: 21px; height: 21px; }
  .tabbar .pastille {
    position: absolute; transform: translate(11px, -9px);
    min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px;
    background: var(--invert-bg); color: var(--invert-ink);
    font-size: .58rem; line-height: 15px; text-align: center; font-family: var(--mono);
  }

  /* Le tiroir latéral reste accessible pour les entrées secondaires */
  .page { padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
  .toast-root { bottom: calc(72px + env(safe-area-inset-bottom)); left: .8rem; right: .8rem; }
  .toast { max-width: none; }

  .topbar { padding-left: max(.9rem, env(safe-area-inset-left)); padding-right: max(.9rem, env(safe-area-inset-right)); }
  .sidebar { padding-bottom: env(safe-area-inset-bottom); }
}

/* Bandeau « hors ligne » */
.offline-bar.on {
  display: block; position: fixed; left: 0; right: 0; top: 0; z-index: 90;
  background: var(--invert-bg); color: var(--invert-ink);
  font-size: .78rem; font-weight: 600; text-align: center; padding: .35rem .8rem;
  padding-top: calc(.35rem + env(safe-area-inset-top));
}

/* Tableaux transformés en fiches empilées */
@media (max-width: 760px) {
  .table-wrap { overflow-x: visible; max-height: none !important; }
  table.data { display: block; }
  table.data thead { display: none; }
  table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr {
    border: 0; border-radius: var(--radius-sm);
    margin: 0 0 .5rem; padding: .65rem .8rem; background: var(--surface-2);
  }
  table.data tr:hover { background: var(--surface-2); }
  table.data tr.inactive { opacity: 1; border-left: 3px solid var(--line-strong); }
  table.data td {
    border: 0; padding: .22rem 0; display: flex; align-items: center;
    justify-content: space-between; gap: 1rem; text-align: right;
  }
  table.data td::before {
    content: attr(data-label);
    color: var(--muted); font-size: .68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .07em; text-align: left; flex: none;
  }
  table.data td[data-label=""]::before, table.data td:not([data-label])::before { display: none; }
  table.data td:first-child {
    justify-content: flex-start; text-align: left; font-size: .95rem;
    padding-bottom: .45rem; margin-bottom: .35rem; border-bottom: 1px solid var(--line);
  }
  table.data td:first-child::before { display: none; } /* intitulé inutile sur l'en-tête de fiche */
  table.data td.num { font-size: .9rem; }
  table.data td .progress-cell { justify-content: flex-end; }
  table.data td:empty { display: none; }
  .card.tight .table-wrap { padding: 0 .8rem .8rem; }
}

@media (max-width: 900px) {
  .grid.k4 { grid-template-columns: repeat(2, 1fr); gap: .7rem; }
  .grid.k3, .grid.k2, .grid.a2, .grid.a3 { grid-template-columns: 1fr; }
  .weapon-grid { grid-template-columns: 1fr 1fr; gap: .7rem; }
  .weapon-card .rows { font-size: .74rem; }
  .weapon-card h4 { font-size: .85rem; }
  .kpi .value { font-size: 1.6rem; }
  .kpi .label { font-size: .64rem; }
  .kpi .foot { font-size: .7rem; }
  .card { padding: .9rem; }
  .page-intro { font-size: .84rem; }
  .donut-wrap { justify-content: center; }
  .detail-head .stat-inline { width: 100%; }
  .toolbar { gap: .45rem; }
  .toolbar .search { flex: 1 1 100%; }
  .search input { width: 100%; }
  .toolbar select.inline { flex: 1 1 45%; min-width: 0; }
  .toolbar .btn-group { flex: 1 1 100%; }
  .toolbar .btn-group .btn { flex: 1; justify-content: center; }
  .toolbar .spacer { display: none; }
}

@media (max-width: 480px) {
  .weapon-grid { grid-template-columns: 1fr; }
  .grid.k4 { grid-template-columns: 1fr 1fr; }
}

/* Confort tactile : cibles plus grandes, pas de zoom automatique sur iOS */
@media (pointer: coarse) {
  .btn { padding: .58rem .9rem; }
  .btn.sm { padding: .42rem .6rem; font-size: .8rem; }
  .btn.icon { padding: .55rem; }
  .field input, .field select, .field textarea,
  .search input, select.inline, .participant-row input, .participant-row select {
    font-size: 16px; /* en dessous, iOS zoome sur le champ */
    padding: .6rem .7rem;
  }
  .check { padding: .45rem .75rem; }
  .nav a { padding: .7rem .65rem; }
  table.data tbody tr.clickable { cursor: default; }
}

/* Modales en feuille plein écran sur mobile */
@media (max-width: 760px) {
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal, .modal.wide, .modal.narrow {
    width: 100%; max-width: none; max-height: 96vh; height: auto;
    border-radius: 16px 16px 0 0; border-bottom: 0;
    animation: monte .22s ease;
  }
  @keyframes monte { from { transform: translateY(100%); } }
  .modal-head {
    position: sticky; top: 0; background: var(--surface); z-index: 2;
    border-radius: 16px 16px 0 0;
  }
  .modal-head::before {
    content: ""; position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
    width: 36px; height: 4px; border-radius: 2px; background: var(--line-strong);
  }
  .modal-head { padding-top: 1.15rem; }
  .modal-body { padding: 1rem .9rem; }
  .modal-foot {
    position: sticky; bottom: 0; padding: .8rem .9rem calc(.8rem + env(safe-area-inset-bottom));
    flex-wrap: wrap;
  }
  .modal-foot .btn { flex: 1; justify-content: center; }
  .modal-foot .spacer { display: none; }
  fieldset { padding: .7rem .8rem; }
}

/* Participants : fiche par agent sur mobile */
@media (max-width: 760px) {
  .participant-row {
    grid-template-columns: 1fr 1fr; gap: .45rem;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: .6rem; margin-bottom: .5rem;
  }
  .participant-row > div:first-child { grid-column: 1 / -1; }
  .participant-row select[data-champ="weaponId"] { grid-column: 1 / -1; }
  .participant-row select[data-champ="aptitude"] { grid-column: 1 / -1; }
  .participant-row [data-retirer] { position: absolute; right: .5rem; margin-top: -.2rem; }
  .participant-row { position: relative; }
}

/* Affichage installé (plein écran) : on retrouve la marge du haut système */
@media (display-mode: standalone) {
  .topbar { padding-top: calc(.85rem + env(safe-area-inset-top)); }
  .sidebar-head { padding-top: calc(1.15rem + env(safe-area-inset-top)); }
  .login-main { padding-top: calc(2rem + env(safe-area-inset-top)); }
}

/* Impression */
@media print {
  .sidebar, .topbar, .toolbar, .btn, .tabs, .tabbar, .offline-bar { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  .page { padding: 0; }
  .card { border: 1px solid #000; break-inside: avoid; }
  body { background: #fff; }
}
