/* TILLA by ARKAN TECHNOLOGY — Made in Djibouti
   Palette inspirée de Djibouti : turquoise du lac Assal, sel blanc, sable du Grand Bara, basalte, corail de la mer Rouge.
   Propriétés logiques (inline-start/end) partout : l'arabe (RTL) fonctionne sans feuille séparée. */
:root {
  --assal: #0e9f94;
  --assal-strong: #077a72;
  --assal-soft: #d8f3ef;
  --basalt: #12202b;
  --basalt-2: #1c2f3d;
  --sand: #f6efe3;
  --sand-2: #ece0cb;
  --salt: #fffdf9;
  --coral: #e8664a;
  --amber: #e9a23b;
  --ink: #17232c;
  --ink-2: #4b5a64;
  --ink-3: #7c8a93;
  --line: #e4d9c6;
  --ok: #138a52;
  --warn: #b7791f;
  --bad: #c0392b;
  --bg: var(--sand);
  --card: var(--salt);
  --rail: var(--basalt);
  --rail-ink: #cfe1e6;
  --shadow: 0 1px 2px rgba(18, 32, 43, .06), 0 8px 24px rgba(18, 32, 43, .06);
  --radius: 18px;
  --radius-sm: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Arabic", "Geeza Pro", Tahoma, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d171f; --card: #15232e; --salt: #15232e; --sand-2: #20323f; --line: #263a48;
    --ink: #e9f1f3; --ink-2: #b2c2c9; --ink-3: #82949d; --assal-soft: #0f3a39; --rail: #08111700; --rail: #08121a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d171f; --card: #15232e; --salt: #15232e; --sand-2: #20323f; --line: #263a48;
  --ink: #e9f1f3; --ink-2: #b2c2c9; --ink-3: #82949d; --assal-soft: #0f3a39; --rail: #08121a;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--assal-strong); }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
:where(svg:not(.brand-mark):not(.flag)) { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; }
.empty svg { width: 42px; height: 42px; opacity: .55; display: block; margin: 0 auto 8px; }
.card h3 svg { color: var(--assal); }
[dir="rtl"] .num, .ltr { direction: ltr; unicode-bidi: isolate; }

/* ---------- Coque applicative ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.rail { background: var(--rail); color: var(--rail-ink); padding: 18px 14px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; scrollbar-width: thin; }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; opacity: .5; padding: 12px 12px 4px; font-weight: 700; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; flex: none; }
.brand b { font-size: 22px; letter-spacing: .12em; display: block; line-height: 1; }
.brand small { font-size: 10.5px; opacity: .7; letter-spacing: .04em; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 12px; color: var(--rail-ink); text-decoration: none; font-weight: 500; }
.nav-link svg { width: 20px; height: 20px; flex: none; opacity: .9; }
.nav-link:hover { background: rgba(255,255,255,.06); }
.nav-link.active { background: var(--assal); color: #fff; }
.nav-link.locked { opacity: .45; }
.rail-foot { margin-top: auto; font-size: 11px; opacity: .6; padding: 8px; }
.rail-foot .flag { display: inline-block; width: 16px; height: 11px; vertical-align: -1px; margin-inline-end: 4px; border-radius: 2px; overflow: hidden; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 22px; position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 19px; margin: 0; margin-inline-end: auto; font-weight: 700; }
.content { padding: 22px; flex: 1; }

/* ---------- Pastille de connexion + bouton hors ligne ---------- */
.conn { display: inline-flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 13px; font-weight: 600; white-space: nowrap; }
[dir="rtl"] .conn { padding: 6px 12px 6px 6px; }
.conn .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.conn[data-state="offline-auto"] .dot { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 25%, transparent); animation: pulse 1.4s infinite; }
.conn[data-state="offline-manual"] .dot { background: var(--amber); box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber) 30%, transparent); }
.conn[data-state="syncing"] .dot { background: var(--assal); animation: pulse .8s infinite; }
.conn .badge { background: var(--coral); color: #fff; border-radius: 999px; padding: 1px 7px; font-size: 11.5px; }
.conn button { display: inline-flex; align-items: center; gap: 5px; border: 0; border-radius: 999px; padding: 5px 11px; background: var(--basalt); color: #fff; cursor: pointer; font-weight: 600; font-size: 12.5px; }
.conn[data-state="offline-manual"] button, .conn[data-state="offline-auto"] button { background: var(--assal); }
@keyframes pulse { 50% { opacity: .35; } }

.offline-band { background: repeating-linear-gradient(-45deg, #fff4dc, #fff4dc 12px, #fbe9c3 12px, #fbe9c3 24px); color: #6b4a0f; padding: 8px 22px; font-size: 13.5px; font-weight: 600; border-bottom: 1px solid #efd9a8; display: flex; gap: 10px; align-items: center; }
.offline-band.auto { background: repeating-linear-gradient(-45deg, #fde5df, #fde5df 12px, #f9d3ca 12px, #f9d3ca 24px); color: #7c2a1a; border-color: #f0c0b4; }

/* ---------- Éléments ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; border: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.card h2, .card h3 { margin: 0 0 12px; font-size: 16px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.kpi { position: relative; overflow: hidden; }
.kpi .label { color: var(--ink-3); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 26px; font-weight: 800; margin-top: 6px; }
.kpi .sub { color: var(--ink-3); font-size: 12.5px; }
.kpi::after { content: ""; position: absolute; inset-inline-end: -26px; top: -26px; width: 90px; height: 90px; border-radius: 50%; background: var(--assal-soft); opacity: .8; }
.kpi.coral::after { background: #fde3dc; } .kpi.amber::after { background: #fbecd2; } .kpi.basalt::after { background: #dfe6ea; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .kpi::after { opacity: .15; } }
.two { grid-template-columns: 2fr 1fr; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 9px 15px; border-radius: 12px; cursor: pointer; font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--assal); }
.btn.primary { background: var(--assal); border-color: var(--assal); color: #fff; }
.btn.primary:hover { background: var(--assal-strong); }
.btn.dark { background: var(--basalt); border-color: var(--basalt); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.big { padding: 14px 20px; font-size: 17px; border-radius: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
.icon-btn { border: 0; background: transparent; cursor: pointer; padding: 6px; border-radius: 8px; color: var(--ink-2); }
.icon-btn:hover { background: var(--sand-2); }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); background: var(--salt); border-radius: 12px; padding: 10px 12px; outline: none; }
.input:focus { border-color: var(--assal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--assal) 20%, transparent); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 160px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 14px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .input { max-width: 320px; }
.tabs { display: inline-flex; background: var(--sand-2); border-radius: 12px; padding: 4px; gap: 4px; }
.tabs button { border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.tabs button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

table.list { width: 100%; border-collapse: collapse; }
.list th { text-align: start; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); padding: 10px; border-bottom: 1px solid var(--line); }
.list td { padding: 11px 10px; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); vertical-align: middle; }
.list tr.click { cursor: pointer; }
.list tr.click:hover td { background: color-mix(in srgb, var(--assal-soft) 45%, transparent); }
.list td.end, .list th.end { text-align: end; }
.table-wrap { overflow-x: auto; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.paid, .pill.synced, .pill.ok { background: #d9f2e5; color: #0b6b3e; }
.pill.due, .pill.failed, .pill.bad { background: #fbe0dc; color: #9b2c1f; }
.pill.partial, .pill.pending, .pill.warn { background: #fbecd2; color: #8a5a11; }
.pill.offline { background: var(--basalt); color: #fff; }
.muted { color: var(--ink-3); }
.empty { text-align: center; color: var(--ink-3); padding: 40px 10px; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; color: var(--ink-3); font-size: 13px; }

/* ---------- Caisse (POS) ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 18px; align-items: start; }
.pos-catalog .cats { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; scrollbar-width: thin; }
.chip { border: 1px solid var(--line); background: var(--card); padding: 6px 13px; border-radius: 999px; cursor: pointer; white-space: nowrap; font-weight: 600; font-size: 13px; }
.chip.on { background: var(--basalt); color: #fff; border-color: var(--basalt); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; min-height: 118px; text-align: start; transition: transform .08s; }
.tile:hover { border-color: var(--assal); }
.tile:active { transform: scale(.98); }
.tile .ph { height: 46px; border-radius: 11px; display: grid; place-items: center; font-weight: 800; font-size: 18px; color: #fff; }
.tile .nm { font-weight: 650; font-size: 13.5px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile .pr { margin-top: auto; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px; }
.tile .pr b { font-size: 15px; }
.tile .st { font-size: 11.5px; color: var(--ink-3); }
.tile .st.low { color: var(--bad); font-weight: 700; }
.ticket { position: sticky; top: 78px; display: flex; flex-direction: column; max-height: calc(100vh - 160px); padding: 0; overflow: hidden; }
.ticket-head { padding: 16px 16px 10px; border-bottom: 1px dashed var(--line); }
.ticket-lines { overflow-y: auto; flex: 1; padding: 6px 10px; min-height: 120px; }
.tline { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 9px 6px; border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.tline .nm { font-weight: 600; font-size: 14px; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.qty button { border: 0; background: var(--sand-2); width: 30px; height: 28px; cursor: pointer; font-size: 16px; font-weight: 700; }
.qty input { width: 52px; border: 0; text-align: center; background: transparent; height: 28px; }
.ticket-foot { padding: 14px 16px 16px; border-top: 1px dashed var(--line); background: color-mix(in srgb, var(--sand-2) 40%, var(--card)); }
.sum-row { display: flex; justify-content: space-between; padding: 3px 0; color: var(--ink-2); }
.sum-row.total { font-size: 22px; font-weight: 800; color: var(--ink); padding-top: 8px; }
.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay-methods button { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 6px; cursor: pointer; font-weight: 600; font-size: 13px; }
.pay-methods button.on { border-color: var(--assal); background: var(--assal-soft); color: var(--assal-strong); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button { padding: 14px; font-size: 18px; font-weight: 700; border-radius: 12px; border: 1px solid var(--line); background: var(--card); cursor: pointer; }
.big-amount { font-size: 34px; font-weight: 800; text-align: center; padding: 8px; }

/* ---------- Modale & synchronisation obligatoire ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(10, 20, 28, .55); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .15s; }
.modal { background: var(--card); border-radius: 22px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.modal.wide { width: min(860px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; margin-inline-end: auto; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
.sync-lock { position: fixed; inset: 0; z-index: 200; background: radial-gradient(1200px 600px at 50% -10%, #0e9f9455, transparent), var(--basalt); color: #fff; display: grid; place-items: center; padding: 20px; }
.sync-box { width: min(520px, 100%); text-align: center; }
.sync-box h2 { font-size: 24px; margin: 18px 0 6px; }
.sync-box p { color: #b9cdd4; margin: 0 0 18px; }
.sync-ring { width: 92px; height: 92px; margin: 0 auto; border-radius: 50%; border: 6px solid rgba(255,255,255,.12); border-top-color: var(--assal); animation: spin 1s linear infinite; }
.sync-ring.done { animation: none; border-color: var(--assal); display: grid; place-items: center; font-size: 40px; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 10px; background: rgba(255,255,255,.12); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--assal), #5fd3c8); width: 0; transition: width .3s; }
.sync-fail { text-align: start; background: rgba(255,255,255,.06); border-radius: 14px; padding: 12px; margin-top: 16px; max-height: 40vh; overflow: auto; }
.sync-fail .it { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.08); }
.sync-fail .it div { flex: 1; font-size: 13.5px; }
.sync-lock .btn { border-color: rgba(255,255,255,.2); background: rgba(255,255,255,.08); color: #fff; }
.sync-lock .btn.primary { background: var(--assal); border-color: var(--assal); }

.toast-zone { position: fixed; bottom: 18px; inset-inline-end: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 300; }
.toast { background: var(--basalt); color: #fff; padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow); max-width: 360px; animation: fade .2s; font-weight: 500; }
.toast.ok { background: var(--ok); } .toast.bad { background: var(--bad); } .toast.warn { background: var(--warn); }

/* ---------- Connexion ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { background: var(--basalt); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art::before { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; background: radial-gradient(circle at 30% 30%, #19c0b1, #0e9f94 40%, transparent 70%); inset-inline-end: -160px; bottom: -180px; opacity: .55; }
.auth-art::after { content: ""; position: absolute; width: 300px; height: 300px; border-radius: 50%; border: 2px dashed rgba(255,255,255,.15); inset-inline-start: -80px; top: 18%; }
.auth-art h1 { font-size: 64px; letter-spacing: .16em; margin: 0; position: relative; }
.auth-art .tag { font-size: 18px; opacity: .85; max-width: 420px; position: relative; }
.auth-art .made { position: relative; font-size: 13px; opacity: .75; display: flex; align-items: center; gap: 8px; }
.auth-form { display: grid; place-items: center; padding: 32px; }
.auth-form form { width: min(380px, 100%); }
.auth-form h2 { font-size: 26px; margin: 0 0 4px; }
.langs { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 22px; }
.langs button { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-weight: 600; font-size: 13px; }
.langs button.on { background: var(--basalt); color: #fff; border-color: var(--basalt); }
.err { color: var(--bad); font-size: 13.5px; min-height: 20px; margin: 6px 0; font-weight: 600; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .b i { width: 100%; max-width: 34px; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, #19c0b1, var(--assal)); min-height: 3px; display: block; }
.bars .b span { font-size: 10.5px; color: var(--ink-3); }
.toplist { list-style: none; margin: 0; padding: 0; }
.toplist li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.mobile-nav { display: none; }

/* ---------- Reçu imprimable ---------- */
.receipt { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 13px; background: #fff; color: #000; padding: 16px; border-radius: 12px; border: 1px dashed #bbb; }
.receipt h4 { text-align: center; margin: 0 0 4px; font-size: 16px; }
.receipt .rcpt-logo { display: block; margin: 0 auto 6px; max-width: 70%; max-height: 72px; object-fit: contain; }
.receipt .c { text-align: center; }
.receipt table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.receipt td { padding: 2px 0; vertical-align: top; }
.receipt .r { text-align: end; }
.receipt hr { border: 0; border-top: 1px dashed #999; }
.receipt .prov { border: 2px solid #000; text-align: center; font-weight: 700; padding: 4px; margin: 6px 0; }
/* Code QR de vérification du ticket : centré, 40 mm imprimé (au moins 0,4 mm par module sur une imprimante 203 dpi) */
.receipt .rcpt-qr { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 10px 0 4px; text-align: center; }
.receipt .rcpt-qr .qr { width: 151px; height: 151px; }
@media print {
  body * { visibility: hidden; }
  .receipt, .receipt * { visibility: visible; }
  .receipt { position: absolute; inset: 0 auto auto 0; width: 80mm; border: 0; }
  .receipt .rcpt-qr .qr { width: 40mm; height: 40mm; }
}

/* ---------- Mobile ---------- */
.pos-bar { display: none; }
@media (max-width: 1100px) { .pos { grid-template-columns: minmax(0, 1fr) 340px; } .two { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  .content { padding: 16px; padding-bottom: 90px; }
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .topbar h1 { font-size: 17px; }
  .pos { grid-template-columns: minmax(0, 1fr); }
  .pos-bar { display: flex; position: fixed; inset-inline: 10px; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 40; gap: 10px; align-items: center; background: var(--basalt); color: #fff; border-radius: 16px; padding: 8px 8px 8px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
  .pos-bar b { flex: 1; }
  .content.has-bar { padding-bottom: 160px; }
  .ticket { position: static; max-height: none; }
  .mobile-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; inset-inline: 0; background: var(--rail); z-index: 50; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .mobile-nav a { color: var(--rail-ink); text-decoration: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; padding: 4px; border-radius: 10px; }
  .mobile-nav a.active { color: #fff; background: var(--assal); }
  .mobile-nav svg { width: 22px; height: 22px; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 28px; min-height: 220px; }
  .auth-art h1 { font-size: 42px; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .conn .lbl { display: none; }
  .hide-sm { display: none !important; }
}

/* ---------- v1.1 : modules ---------- */
.seg { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--sand-2); color: var(--ink-2); white-space: nowrap; }
.seg.new { background: var(--assal-soft); color: var(--assal); }
.seg.active { background: #dcf3e4; color: #137a3c; }
.seg.at_risk { background: #fbecd2; color: #9a5b00; }
.seg.inactive, .seg.never { background: #fde3dc; color: #b23b1e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg.active { background: #12351f; color: #7fd6a0; } :root:not([data-theme="light"]) .seg.at_risk { background: #3a2a0c; color: #f0c06a; } :root:not([data-theme="light"]) .seg.inactive, :root:not([data-theme="light"]) .seg.never { background: #3d1a12; color: #f3a08a; } }
:root[data-theme="dark"] .seg.active { background: #12351f; color: #7fd6a0; } :root[data-theme="dark"] .seg.at_risk { background: #3a2a0c; color: #f0c06a; } :root[data-theme="dark"] .seg.inactive, :root[data-theme="dark"] .seg.never { background: #3d1a12; color: #f3a08a; }
.perm-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.perm-chips span { font-size: 11.5px; padding: 3px 8px; border-radius: 8px; background: var(--sand-2); color: var(--ink-2); font-family: ui-monospace, Menlo, monospace; }
.perm-group { margin-top: 10px; } .perm-group b { font-size: 12.5px; }
.readonly-note { display: flex; gap: 8px; align-items: center; color: var(--ink-3); font-size: 13px; margin-bottom: 14px; }
.readonly-note svg { width: 16px; height: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.acc-type { margin-top: 18px; } .acc-type h3 { display: flex; justify-content: space-between; }
.diff-ok { color: var(--assal); font-weight: 700; } .diff-bad { color: var(--coral); font-weight: 700; }
.z-report { max-width: 520px; }
.menu-sheet { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.menu-sheet a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; border-radius: 14px; background: var(--sand-2); border: 1px solid var(--line); color: var(--ink); font-weight: 600; text-decoration: none; font-size: 12.5px; text-align: center; }
.menu-sheet a svg { width: 22px; height: 22px; color: var(--assal); }
.menu-sheet a.active svg { color: #fff; }
.menu-sheet a.active { border-color: var(--assal); }
.menu-sheet a.active { background: var(--assal); color: #fff; }
.mobile-nav button { background: none; border: 0; color: var(--rail-ink); font: inherit; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; padding: 4px; border-radius: 10px; cursor: pointer; }
.tline-return input { width: 90px; }
.tabs-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }

/* v1.2 : paiements mobiles */
.check { display: flex; gap: 8px; align-items: center; margin: 4px 0 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--assal); }
.mp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.mp-card { display: flex; align-items: center; gap: 10px; text-align: start; border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 10px 12px; cursor: pointer; color: inherit; font: inherit; }
.mp-card:hover { border-color: var(--assal); }
.mp-card.on { border-color: var(--assal); box-shadow: inset 0 0 0 1px var(--assal); }
.mp-logo { width: 38px; height: 38px; border-radius: 11px; color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: .5px; flex: none; }
.mp-name { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.mp-name small { color: var(--ink-2); font-size: 12px; }
.mp-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-inline-end: 6px; vertical-align: middle; }
.mp-test h4 { margin: 0 0 8px; display: flex; gap: 6px; align-items: center; }
.mp-test h4 svg, .mp-pay svg { width: 18px; height: 18px; }
.mp-adv summary { cursor: pointer; font-weight: 600; margin: 6px 0; }
.mp-pay { border: 1px dashed var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.mp-pay .merchant { font-size: 20px; font-weight: 800; letter-spacing: 1px; }
.mp-wait { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--assal); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.linkish { background: none; border: 0; color: var(--assal); text-decoration: underline; cursor: pointer; padding: 0; font: inherit; }

/* ---------- Module Gym ---------- */
.gym-packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.gym-pack { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; text-align: start; border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 10px 12px; cursor: pointer; color: inherit; font: inherit; }
.gym-pack span { font-size: 12.5px; color: var(--ink-2); }
.gym-pack:hover { border-color: var(--assal); }
.gym-pack.on { border-color: var(--assal); box-shadow: inset 0 0 0 1px var(--assal); background: var(--assal-soft); }
.gym-code { font-size: 18px; letter-spacing: .5px; }
.gym-verdict { display: flex; gap: 14px; align-items: flex-start; margin-top: 14px; padding: 16px; border-radius: var(--radius-sm); border: 1px dashed var(--line); min-height: 96px; }
.gym-verdict.ok { border: 0; background: #d9f2e5; color: #0b4d2e; }
.gym-verdict.bad { border: 0; background: #fbe0dc; color: #7c2318; }
:root[data-theme="dark"] .gym-verdict.ok { background: #12351f; color: #b7ecc9; }
:root[data-theme="dark"] .gym-verdict.bad { background: #3d1a12; color: #f6c2b5; }
.gym-v-title { font-size: 22px; font-weight: 800; }
.gym-v-name { font-weight: 700; margin: 2px 0 4px; }
.gym-avatar { width: 56px; height: 56px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--basalt); color: #fff; }
.gym-verdict.ok .gym-avatar { background: var(--ok); }
.gym-verdict.bad .gym-avatar { background: var(--bad); }
.gym-avatar.big { width: 72px; height: 72px; font-size: 24px; background: var(--assal); }
.gym-ev { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.gym-ev:last-child { border-bottom: 0; }
.gym-ev-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--ink-3); }
.gym-ev.granted .gym-ev-dot { background: var(--ok); }
.gym-ev.denied .gym-ev-dot { background: var(--bad); }
.gym-recep [data-feed] { max-height: 420px; overflow-y: auto; }
.gym-pkg { text-align: start; cursor: pointer; color: inherit; font: inherit; border: 1px solid transparent; }
.gym-pkg:hover { border-color: var(--assal); }
.gym-pkg.off { opacity: .55; }
.gym-pkg-name { font-weight: 800; font-size: 17px; }
.gym-pkg-price { font-size: 24px; font-weight: 800; color: var(--assal-strong); margin: 4px 0; }
.gym-dev .row { flex-wrap: wrap; }
.gym-brand { display: inline-block; padding: 3px 9px; border-radius: 8px; font-size: 12px; font-weight: 800; color: #fff; background: var(--basalt); }
.gym-brand.hikvision { background: #c8102e; }
.gym-brand.dahua { background: #1d4f9c; }
.gym-brand.zkteco { background: #2e8b3e; }
.gym-unknown { margin-bottom: 16px; border-inline-start: 4px solid var(--amber); }
.gym-agents { margin-bottom: 16px; }
.gym-agent { gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.gym-ev-dot.on { background: var(--ok); }
.gym-ev-dot.off { background: var(--bad); }
.gym-steps { padding-inline-start: 20px; display: grid; gap: 10px; }
.gym-cmd { background: var(--basalt); color: #e9f1f3; padding: 10px 12px; border-radius: 10px; font-size: 12.5px; white-space: pre-wrap; word-break: break-all; margin: 6px 0; }
.sa-mod { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }

/* v2.0 : caisse par module (produits / abonnements de la salle de sport) */
.pos-modes { flex-shrink: 0; }
.pos-modes button svg, .gym-tile .ph svg { width: 18px; height: 18px; vertical-align: -3px; }
.gym-pos [data-gtabs] { flex-shrink: 0; }
.gym-tile .ph { color: #fff; }
.tile.on { border-color: var(--assal); box-shadow: inset 0 0 0 1px var(--assal); background: var(--assal-soft); }
.gym-members { display: flex; flex-direction: column; gap: 8px; }
.gym-mrow { display: flex; gap: 12px; align-items: center; text-align: start; border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 10px 12px; cursor: pointer; color: inherit; font: inherit; }
.gym-mrow:hover { border-color: var(--assal); }
.gym-mrow.on { border-color: var(--assal); box-shadow: inset 0 0 0 1px var(--assal); background: var(--assal-soft); }
.gym-mrow small { display: block; }
.gym-mrow .end { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: end; }
.gym-who { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.gym-who small { display: block; margin-top: 2px; }
.gym-who svg { width: 14px; height: 14px; vertical-align: -2px; }
.module-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.module-opt { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; background: var(--card); }
.module-opt input { margin-top: 3px; }
.module-opt small { display: block; color: var(--ink-3); font-size: 12px; }
.module-opt:has(input:checked) { border-color: var(--assal); background: var(--assal-soft); }
/* v2.8.1 : langues proposées par l'entreprise */
.lang-list { display: flex; flex-wrap: wrap; gap: 8px; }
.lang-opt { display: inline-flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; background: var(--card); font-weight: 600; font-size: 13px; }
.lang-opt:has(input:checked) { border-color: var(--assal); background: var(--assal-soft); }
.module-pills { display: flex; flex-wrap: wrap; gap: 4px; }
.perm-edit { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.perm-edit fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin: 0; }
.perm-edit legend { font-weight: 700; padding: 0 4px; }
.perm-edit label { display: flex; gap: 8px; align-items: center; font-size: 13px; padding: 2px 0; }

/* ---------- Documents A4 (facture, devis, bon de livraison, avoir, bon de commande, Zakat) ---------- */
.modal.doc-modal { width: min(920px, 100%); }
.doc-wrap { background: var(--sand-2, #ece6da); padding: 14px; border-radius: 12px; overflow-x: auto; }
.a4doc { --doc: #0e9f94; background: #fff; color: #14212b; width: 100%; max-width: 794px; min-height: 1000px; margin: 0 auto; padding: 40px 44px 28px;
  box-shadow: 0 6px 24px rgba(0,0,0,.08); display: flex; flex-direction: column; gap: 18px; font-size: 13px; line-height: 1.45; border-top: 8px solid var(--doc); }
.a4doc h1, .a4doc h2, .a4doc h4, .a4doc p { margin: 0; }
.doc-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.doc-biz { display: flex; gap: 14px; align-items: flex-start; }
.doc-biz h2 { font-size: 19px; color: #14212b; margin-bottom: 4px; }
.doc-biz p { color: #55626b; font-size: 12.5px; }
.doc-logo { max-width: 120px; max-height: 70px; object-fit: contain; }
.doc-title { text-align: end; position: relative; }
.doc-title h1 { font-size: 26px; letter-spacing: .06em; text-transform: uppercase; color: var(--doc); margin-bottom: 8px; }
.doc-title table { margin-inline-start: auto; border-collapse: collapse; font-size: 12.5px; }
.doc-title td { padding: 1px 0 1px 12px; text-align: end; }
.doc-title td:first-child { color: #6b7780; }
.doc-stamp { display: inline-block; margin-top: 10px; padding: 4px 12px; border: 2px solid; border-radius: 6px; font-weight: 700; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; transform: rotate(-4deg); }
.doc-stamp.paid { color: #13824a; } .doc-stamp.partial { color: #b7791f; } .doc-stamp.due { color: #c0392b; }
.doc-party { background: #f6f3ec; border-inline-start: 4px solid var(--doc); padding: 12px 16px; border-radius: 6px; max-width: 360px; }
.doc-party h4, .doc-block h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6b7780; margin-bottom: 4px; }
.doc-lines { width: 100%; border-collapse: collapse; }
.doc-lines th { background: var(--doc); color: #fff; font-weight: 600; font-size: 12px; padding: 8px 10px; text-align: start; }
.doc-lines th.end, .doc-lines td.end, .doc-totals td.end, .doc-pays td.end { text-align: end; }
.doc-lines td { padding: 8px 10px; border-bottom: 1px solid #ebe6dc; vertical-align: top; }
.doc-lines tbody tr:nth-child(even) td { background: #faf8f3; }
.doc-lines .n { width: 28px; color: #6b7780; }
.doc-lines small, .doc-pays small { color: #6b7780; }
.doc-lines .tick { display: inline-block; width: 16px; height: 16px; border: 1.5px solid #9aa4ab; border-radius: 3px; }
.doc-sum { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.doc-sum > div { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.doc-totals { border-collapse: collapse; min-width: 270px; }
.doc-totals.wide { width: 100%; }
.doc-totals td { padding: 6px 10px; border-bottom: 1px solid #ebe6dc; }
.doc-totals tr.grand td { font-weight: 700; font-size: 15px; background: #f6f3ec; border-bottom: 2px solid var(--doc); }
.doc-totals tr.due td { color: #c0392b; font-weight: 700; }
.doc-totals tr.head td { font-weight: 700; color: var(--doc); text-transform: uppercase; font-size: 11.5px; letter-spacing: .06em; }
.doc-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.doc-words { font-style: italic; color: #33414b; }
.doc-pays { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.doc-pays td { padding: 3px 0; padding-inline-end: 10px; }
.doc-note { color: #33414b; }
.doc-signs { display: flex; gap: 24px; margin-top: 8px; }
.doc-signs > div { flex: 1; border: 1px dashed #b9c0c5; border-radius: 6px; height: 90px; padding: 8px 10px; color: #6b7780; font-size: 12px; }
.doc-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; border-top: 1px solid #ebe6dc; padding-top: 12px; font-size: 11.5px; color: #55626b; }
.doc-foot .muted { color: #8a949b; }
/* Code QR de vérification dans l'en-tête, à côté du titre : 34 mm imprimé */
.doc-side { display: flex; gap: 22px; align-items: flex-start; }
.doc-qr { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; flex: none; }
.doc-qr .qr { width: 128px; height: 128px; }
.doc-qr small { font-size: 10px; color: #6b7780; text-transform: uppercase; letter-spacing: .08em; }
@media (max-width: 700px) { .a4doc { padding: 22px 18px; min-height: 0; font-size: 12px; } .doc-head, .doc-sum { flex-direction: column; } .doc-side { width: 100%; justify-content: space-between; } .doc-title { text-align: start; } .doc-title table { margin-inline-start: 0; } .doc-totals { min-width: 0; width: 100%; } .doc-grid2 { grid-template-columns: 1fr; } }
@page a4 { size: A4; margin: 10mm; }
@media print {
  body.print-a4 * { visibility: hidden; }
  body.print-a4 .a4doc, body.print-a4 .a4doc * { visibility: visible; }
  body.print-a4 .a4doc { page: a4; position: absolute; inset: 0 auto auto 0; width: 100%; max-width: none; min-height: 0; box-shadow: none; padding: 0 2mm; border-top-width: 6px; }
  body.print-a4 .doc-wrap, body.print-a4 .modal-body { padding: 0; background: none; overflow: visible; }
  body.print-a4 .modal-back { position: static; }
  .a4doc * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body.print-a4 .doc-qr .qr { width: 34mm; height: 34mm; }
}
/* v2.9 : bulletins de paie AJR (impression groupée : un bulletin par page) */
.a4doc.payslip .doc-lines tr.sub td { border-top: 2px solid var(--doc); background: color-mix(in srgb, var(--doc) 7%, transparent); }
.toplist li > .pill { align-self: center; white-space: nowrap; }
.payslip-print { display: none; }
@media print {
  body.print-a4 .payslip-print { display: block; position: absolute; inset: 0 auto auto 0; width: 100%; }
  body.print-a4 .payslip-print .a4doc { position: static; break-after: page; }
  body.print-a4 .payslip-print .a4doc:last-child { break-after: auto; }
}
.register-mods { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 12px 0; }
.register-mods .label svg { width: 16px; height: 16px; vertical-align: -3px; }
.register-covers { font-size: 13px; background: var(--sand-2); border-radius: 10px; padding: 8px 12px; }
.quote-band { display: flex; align-items: center; gap: 8px; background: #fff6df; color: #7a5a12; border-radius: 10px; padding: 6px 10px; margin: 8px 12px 0; font-size: 13px; }
.quote-band .icon-btn { margin-inline-start: auto; }
.quote-band svg { width: 16px; height: 16px; }
.pay-left { display: flex; justify-content: space-between; align-items: center; background: var(--sand-2); border-radius: 10px; padding: 8px 12px; margin-top: 8px; font-size: 15px; }
.pay-parts { margin: 6px 0; }
.pay-parts small { color: var(--ink-3); }
.pay-opt { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.pay-opt .input { max-width: 260px; }
.zakat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.zakat-result { text-align: center; padding: 18px; }
.zakat-result .value { font-size: 30px; font-weight: 700; }
.zakat-result.due .value { color: var(--assal, #0e9f94); }
.logo-prev { max-width: 140px; max-height: 70px; object-fit: contain; display: block; margin: 6px 0; }

/* ---------- Enrôlement : empreinte, visage, carte (v2.2) ---------- */
.enroll-head { align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.enroll-hint { font-size: 12.5px; margin: 8px 0 12px; }
.enroll-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.enroll-box { display: flex; flex-direction: column; gap: 10px; padding: 14px; margin: 0; }
.enroll-box h4 { display: flex; align-items: center; gap: 8px; margin: 0; }
.enroll-box h4 svg { width: 20px; height: 20px; color: var(--assal); }
.enroll-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.enroll-list { margin: 0; font-size: 13px; }
.enroll-list li { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.enroll-wait { margin: 0; padding: 8px 10px; border-radius: 10px; background: var(--sand-2); font-size: 13px; }
.enroll-face { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--sand-2); display: grid; place-items: center; }
.enroll-face img, .enroll-face video { width: 100%; height: 100%; object-fit: cover; }
.enroll-face > span svg { width: 56px; height: 56px; opacity: .45; }
.enroll-shoot { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); }
.small { font-size: 12px; margin: 0; }
@media (max-width: 860px) { .enroll-grid { grid-template-columns: 1fr; } .enroll-face { max-width: 260px; margin: 0 auto; width: 100%; } }

/* ---------- v2.3 : rapports, export / import, données ---------- */
.btn.sm { padding: 5px 11px; font-size: 13px; min-height: 0; }
.rep-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 16px; align-items: start; }
.rep-nav { padding: 10px 8px; position: sticky; top: 12px; max-height: calc(100vh - 110px); overflow: auto; }
.rep-group { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); padding: 12px 10px 4px; }
.rep-link { display: block; width: 100%; text-align: start; background: none; border: 0; padding: 7px 10px; border-radius: 10px; color: var(--ink-2); font: inherit; font-size: 14px; cursor: pointer; }
.rep-link:hover { background: var(--sand-2); color: var(--ink); }
.rep-link.active { background: var(--assal-soft); color: var(--assal-strong); font-weight: 700; }
.rep-select { display: none; }
.rep-head h2 { margin: 0 0 2px; font-size: 20px; }
.rep-head p { margin: 0 0 12px; }
.rep-filters { flex-wrap: wrap; gap: 8px; }
.rep-kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 14px; }
.rep-kpis .value { font-size: 21px; }
.rep-chart { margin-bottom: 14px; display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 220px) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 10px; background: var(--sand-2); border-radius: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--assal); border-radius: 6px; }
.report-table tfoot td { font-weight: 800; border-top: 2px solid var(--line); }
.report-table tr.rs-sub td { font-weight: 700; border-top: 1px solid var(--line); }
.report-table tr.rs-total td { font-weight: 800; background: var(--assal-soft); }
.report-table tr.rs-grand td { font-weight: 800; font-size: 15px; background: var(--assal-soft); border-top: 2px solid var(--assal); }
.report-table tr.rs-indent td:first-child { padding-inline-start: 26px; color: var(--ink-2); }
.report-table tr.rs-warn td { background: #fbecd2; } .report-table tr.rs-bad td { background: #fde3dc; }
:root[data-theme="dark"] .report-table tr.rs-warn td { background: #3a2a0c; } :root[data-theme="dark"] .report-table tr.rs-bad td { background: #3d1a12; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .report-table tr.rs-warn td { background: #3a2a0c; } :root:not([data-theme="light"]) .report-table tr.rs-bad td { background: #3d1a12; } }
.dt-h { display: flex; align-items: center; gap: 8px; margin: 6px 0 8px; }
.dt-list { display: grid; gap: 6px; margin-bottom: 8px; }
.dt-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.dt-row .row { gap: 6px; flex-wrap: nowrap; }
.imp-box { padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 10px; }
.imp-drop { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; padding: 18px; border: 2px dashed var(--line); border-radius: var(--radius-sm); cursor: pointer; color: var(--ink-2); text-align: center; }
.imp-drop:hover { border-color: var(--assal); color: var(--assal-strong); }
.imp-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.imp-summary { padding: 12px; border-radius: var(--radius-sm); background: var(--assal-soft); margin-top: 10px; }
.imp-summary.has-errors { background: #fde3dc; }
:root[data-theme="dark"] .imp-summary.has-errors { background: #3d1a12; }
.imp-summary p { margin: 0 0 6px; }
.imp-errors { max-height: 240px; overflow: auto; background: var(--card); border-radius: 8px; margin-bottom: 8px; }
.imp-summary details { margin-top: 6px; } .imp-summary details .table-wrap { max-height: 260px; overflow: auto; background: var(--card); border-radius: 8px; }
.warn-text { color: #8a5a11; font-weight: 700; }
.ext-row > span:first-child { min-width: 0; }
.ext-row .row { flex-wrap: nowrap; align-items: center; }
.bad-text { color: var(--bad); font-weight: 700; } .ok-text { color: var(--ok); font-weight: 700; }
.dc-card h3 { display: flex; align-items: center; gap: 8px; }
.report-print { display: none; }
@media (max-width: 860px) {
  .rep-layout { grid-template-columns: 1fr; }
  .rep-nav { display: none; }
  .rep-select { display: block; width: 100%; }
  .rep-export { width: 100%; }
}
@page report { size: A4 landscape; margin: 9mm; }
@media print {
  body.print-report > *:not(.report-print) { display: none !important; }
  body.print-report .report-print, body.print-report .report-print * { visibility: visible; }
  body.print-report .report-print { display: block; position: absolute; inset: 0 auto auto 0; width: 100%; page: report; color: #14212b; background: #fff; font-size: 10.5px; }
  .report-print header { border-bottom: 3px solid #0e9f94; margin-bottom: 8px; padding-bottom: 6px; }
  .report-print header .rp-logo { float: inline-end; max-width: 150px; max-height: 48px; object-fit: contain; }
  .report-print header h1 { margin: 2px 0; font-size: 17px; }
  .report-print header p { margin: 0; color: #4b5a64; }
  .report-print table { width: 100%; border-collapse: collapse; }
  .report-print th, .report-print td { padding: 3px 5px; border-bottom: 1px solid #ddd; text-align: start; }
  .report-print th { background: #e8f6f4; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .report-print .end { text-align: end; }
  .report-print tfoot td { font-weight: 800; border-top: 2px solid #0e9f94; }
  .report-print tr.rs-total td, .report-print tr.rs-grand td { font-weight: 800; background: #e8f6f4; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .report-print .rp-kpis { display: flex; gap: 18px; margin-bottom: 8px; flex-wrap: wrap; }
  .report-print .rp-kpis div { display: flex; flex-direction: column; }
  .report-print footer { margin-top: 8px; color: #7c8a93; font-size: 9px; }
}

/* ---------- v2.3 : notifications, documentation, document partagé ---------- */
.ntf-card h3 { display: flex; align-items: center; gap: 8px; }
.ntf-test { margin-top: 12px; gap: 8px; }
.ntf-test .input { flex: 1; min-width: 0; }
.ntf-events { display: grid; gap: 8px; margin-top: 10px; }
.ntf-ev { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.ntf-ev-on span { display: flex; flex-direction: column; }
.ntf-ev-ch { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.ntf-days { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.ntf-days .input { width: 64px; padding: 6px 8px; }
.ntf-vars { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ntf-vars .pill { cursor: pointer; border: 1px solid var(--line); font-family: ui-monospace, monospace; }
.ntf-log td { vertical-align: top; }
.sa-invite { border: 1px dashed var(--line); border-radius: 12px; padding: 10px 12px; }
.small { font-size: 12.5px; }
.help-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.help-layout > * { min-width: 0; }
.help-body { overflow-wrap: anywhere; }
.help-toc { position: sticky; top: 78px; max-height: calc(100vh - 100px); overflow: auto; display: grid; gap: 4px; }
.help-toc nav { display: grid; gap: 2px; margin-top: 8px; }
.help-toc a { padding: 7px 10px; border-radius: 9px; color: var(--ink); text-decoration: none; font-size: 14px; }
.help-toc a:hover { background: var(--sand-2); }
.help-toc a.on { background: color-mix(in srgb, var(--assal) 14%, transparent); font-weight: 600; }
.help-g { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 12px 10px 2px; }
.help-sel { display: none; }
.help-body { line-height: 1.6; max-width: 860px; }
.help-body h2 { margin-top: 0; }
.help-body h3 { margin: 22px 0 6px; }
.help-body li { margin: 3px 0; }
.help-body code { background: var(--sand-2); padding: 1px 6px; border-radius: 6px; font-size: .92em; }
.help-tip { display: flex; gap: 8px; align-items: flex-start; background: color-mix(in srgb, var(--assal) 9%, transparent); border-radius: 10px; padding: 10px 12px; }
.help-tip svg { flex: none; width: 18px; height: 18px; margin-top: 2px; }
@media (max-width: 900px) {
  .help-layout { grid-template-columns: minmax(0, 1fr); }
  .help-toc { position: static; max-height: none; }
  .help-toc nav { display: none; }
  .help-sel { display: block; margin-top: 8px; }
  .ntf-ev { grid-template-columns: 1fr; }
}
body.public-doc { background: #efe8da; min-height: 100vh; }
.pd-bar { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: #12202b; color: #fff; letter-spacing: .15em; }
.pd-main { padding: 18px 12px 40px; display: flex; justify-content: center; }
.pd-main .a4doc { margin: 0 auto; }
/* v2.4 : utilisateurs présents dans les terminaux */
.gym-devcount svg, .du-marks svg { width: 15px; height: 15px; vertical-align: -3px; }
.du-marks { white-space: nowrap; color: var(--ink-2); }
.du-marks svg + svg { margin-inline-start: 4px; }

/* Installateur Windows du relais (v2.5) */
.gym-win { background: var(--sand-2); border-radius: 10px; padding: 12px 14px; }
.gym-win h4 { margin: 0 0 4px; }

/* v2.6 : paiements et remise d'un abonnement */
.bill-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.bill-kpis { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 14px; }
.bill-kpis .value { font-size: 1.25rem; }
.bill-form { margin-top: 14px; }

/* v2.7 : clients et fournisseurs « entreprise » ou « individuel », personnes à contacter, grand livre */
.ctype-switch { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--sand-2); border: 1px solid var(--line); }
.ctype-switch label { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.ctype-switch label svg { width: 17px; height: 17px; }
.ctype-switch input { position: absolute; opacity: 0; pointer-events: none; }
.ctype-switch label:has(input:checked) { background: var(--assal); color: #fff; }
.ctype-switch label:has(input:focus-visible) { outline: 2px solid var(--assal); outline-offset: 2px; }
.persons { margin-top: 14px; }
.persons h4 { margin: 0 0 2px; }
.person-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1.3fr auto auto; gap: 6px; align-items: center; margin: 6px 0; }
.person-row .check { white-space: nowrap; font-size: 13px; }
@media (max-width: 760px) { .person-row { grid-template-columns: 1fr 1fr; padding: 8px; border: 1px dashed var(--line); border-radius: 12px; } }
.ctype svg { width: 15px; height: 15px; vertical-align: -2px; color: var(--assal); }
.ledger td { vertical-align: top; }
.ledger tfoot td { font-weight: 800; border-top: 2px solid var(--line); }
.ref-new { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; padding: 8px; border: 1px dashed var(--line); border-radius: 12px; }
.ref-new .input { flex: 1 1 140px; }
/* v2.8 : description des produits, étiquettes des lignes et ruban du devis */
.doc-desc { font-size: .86em; color: #4b5a64; white-space: pre-line; margin-top: 2px; max-width: 46ch; }
.doc-tag { display: inline-block; white-space: nowrap; font-size: 10.5px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; padding: 1px 7px; border-radius: 999px; vertical-align: 1px; margin-inline-start: 4px;
  -webkit-print-color-adjust: exact; print-color-adjust: exact; border: 1px solid currentColor; }
.tag-recommended { --tagc: #0b7f76; --tagb: #e2f5f3; }
.tag-essential { --tagc: #b23b1e; --tagb: #fde3dc; }
.tag-optional { --tagc: #4b5a64; --tagb: #eef1f3; }
.tag-alternative { --tagc: #6a4bb3; --tagb: #eee8fa; }
.tag-promo { --tagc: #9a5b00; --tagb: #fbecd2; }
.doc-tag { color: var(--tagc); background: var(--tagb); }
.a4doc.has-ribbon { position: relative; overflow: hidden; }
.doc-ribbon { position: absolute; top: 0; inset-inline-end: 0; width: 120px; height: 120px; overflow: hidden; pointer-events: none; z-index: 1; }
.doc-ribbon span { position: absolute; top: 26px; right: -46px; width: 180px; transform: rotate(45deg); text-align: center; font-weight: 800; font-size: 12.5px; letter-spacing: .08em;
  text-transform: uppercase; padding: 6px 0; color: #fff; background: var(--tagc); box-shadow: 0 3px 8px rgba(0,0,0,.18); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
[dir="rtl"] .doc-ribbon span { right: auto; left: -46px; transform: rotate(-45deg); }
.a4doc.has-ribbon .doc-head { padding-inline-end: 62px; }
@media (max-width: 700px) { .a4doc.has-ribbon .doc-head { padding-inline-end: 0; padding-top: 34px; } }
.quote-lines { display: grid; gap: 8px; }
.quote-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; }
.quote-line .nm { font-weight: 600; }
.quote-line select { width: auto; }
