/* iCompta — feuille de style (thèmes clair / sombre, responsive) */
:root {
  --accent: #3b82f6;
  --radius: 12px;
  --radius-s: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --side-w: 248px;
  --top-h: 60px;
}
html[data-theme="light"] {
  --bg: #f4f6fa; --bg2: #ffffff; --bg3: #eef1f6; --line: #dde2ea; --line2: #c9d0db;
  --tx: #0f172a; --tx2: #475569; --tx3: #7b8798;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.06);
  --ok: #15803d; --ok-bg: #dcfce7; --bad: #b91c1c; --bad-bg: #fee2e2; --warn: #a16207; --warn-bg: #fef3c7;
  --info: #1d4ed8; --info-bg: #dbeafe; --muted-bg: #e9edf3;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #07090e; --bg2: #10141c; --bg3: #171c26; --line: #222a37; --line2: #2f3a4b;
  --tx: #f1f5f9; --tx2: #a7b2c3; --tx3: #6e7a8c;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 8px 24px rgba(0,0,0,.35);
  --ok: #4ade80; --ok-bg: rgba(74,222,128,.12); --bad: #f87171; --bad-bg: rgba(248,113,113,.13); --warn: #fbbf24; --warn-bg: rgba(251,191,36,.13);
  --info: #60a5fa; --info-bg: rgba(96,165,250,.13); --muted-bg: rgba(148,163,184,.12);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 var(--font); background: var(--bg); color: var(--tx); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.25; }
h1 { font-size: 1.5rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }
.ic { flex: none; vertical-align: middle; }
.muted { color: var(--tx2); }
.dim { color: var(--tx3); }
.small { font-size: .85em; }
.mono { font-family: var(--mono); font-size: .92em; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; } .mt0 { margin-top: 0; }
.grow { flex: 1; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }

/* ---------- Structure ---------- */
.app { display: flex; min-height: 100vh; }
.side {
  width: var(--side-w); background: var(--bg2); border-right: 1px solid var(--line);
  position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 40;
  transition: transform .25s ease;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 16px 18px; color: var(--tx); text-decoration: none !important; border-bottom: 1px solid var(--line); min-height: var(--top-h); }
.logo-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; letter-spacing: -.02em; }
.brand-txt { display: flex; flex-direction: column; min-width: 0; }
.brand-txt small { color: var(--tx3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.nav { padding: 10px; flex: 1; overflow-y: auto; }
.nav-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--tx3); font-weight: 600; padding: 14px 12px 4px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 7px 12px; border-radius: 9px; color: var(--tx2); font-weight: 500; text-decoration: none; margin-bottom: 2px; }
.nav a:hover { background: var(--bg3); color: var(--tx); }
.nav a.on { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.side-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.main { flex: 1; margin-left: var(--side-w); min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; gap: 12px;
  padding: 0 24px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.content { padding: 24px; max-width: 1280px; width: 100%; margin: 0 auto; padding-bottom: 60px; }
.scrim { display: none; }
.tabbar { display: none; }
.only-m { display: none !important; }

.gsearch { flex: 1; max-width: 520px; position: relative; display: flex; align-items: center; gap: 8px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; color: var(--tx3); }
.gsearch:focus-within { border-color: var(--accent); }
.gsearch input { border: 0; background: transparent; padding: 9px 0; width: 100%; color: var(--tx); font: inherit; outline: none; }
.gs-results { position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); display: none; max-height: 60vh; overflow: auto; z-index: 50; }
.gs-results.open { display: block; }
.gs-results a { display: flex; gap: 10px; padding: 9px 14px; color: var(--tx); text-decoration: none; align-items: center; border-bottom: 1px solid var(--line); }
.gs-results a:last-child { border-bottom: 0; }
.gs-results a:hover, .gs-results a.sel { background: var(--bg3); }
.gs-results .gs-k { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--tx3); width: 64px; flex: none; }
.top-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }

/* ---------- Boutons ---------- */
.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--line2); background: var(--bg2); color: var(--tx); font: 500 14px/1.2 var(--font); cursor: pointer;
  text-decoration: none !important; white-space: nowrap; min-height: 38px; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--bg3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
html[data-theme="dark"] .btn.ok { color: #06240f; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line2)); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg3); }
.btn.sm { padding: 5px 10px; min-height: 30px; font-size: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-icon { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--tx2); cursor: pointer; }
.btn-icon:hover { background: var(--bg3); color: var(--tx); }
.btn-icon.sm { width: 30px; height: 30px; }
html[data-theme="dark"] .i-moon, html[data-theme="light"] .i-sun { display: none; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.dropdown { position: relative; }
.dd-menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 220px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; display: none; z-index: 60; }
.dd-menu.right { left: auto; right: 0; }
.dropdown.open .dd-menu { display: block; }
.dd-menu a, .dd-menu button { display: flex; width: 100%; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 7px; color: var(--tx); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.dd-menu a:hover, .dd-menu button:hover { background: var(--bg3); }
.dd-menu .danger { color: var(--bad); }

/* ---------- Cartes / grilles ---------- */
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid > .card, .grid > a.card { margin-top: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-h h2 { margin: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-h { padding: 14px 18px 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.kpi { padding: 16px 18px; }
.kpi .k-l { color: var(--tx2); font-size: 13px; display: flex; gap: 8px; align-items: center; }
.kpi .k-v { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .k-s { color: var(--tx3); font-size: 12.5px; }
.kpi.accent { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.kpi.bad .k-v { color: var(--bad); }
.page-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-h h1 { margin: 0; }
.page-h .sub { color: var(--tx2); margin-top: 2px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-bad { background: var(--bad-bg); color: var(--bad); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-info { background: var(--info-bg); color: var(--info); }
.b-muted { background: var(--muted-bg); color: var(--tx2); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11px; background: var(--bg3); color: var(--tx2); border: 1px solid var(--line); }

/* ---------- Tableaux ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--tx3); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--bg2); }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th.num { text-align: right; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: var(--bg3); }
.tbl tfoot td { font-weight: 700; border-top: 2px solid var(--line2); border-bottom: 0; }
.tbl .t-main { font-weight: 600; color: var(--tx); }
.tbl .t-sub { font-size: 12.5px; color: var(--tx3); }
.empty { text-align: center; padding: 40px 16px; color: var(--tx3); }
.empty .ic { width: 40px; height: 40px; opacity: .5; margin-bottom: 8px; }

/* ---------- Filtres ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters .input, .filters select { width: auto; min-width: 140px; }
.filters .input.search { flex: 1; min-width: 200px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line2); background: var(--bg2); color: var(--tx2); font-size: 13px; font-weight: 500; text-decoration: none !important; white-space: nowrap; }
.chip:hover { color: var(--tx); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Formulaires ---------- */
label.f { display: block; }
label.f > span, .f-l { display: block; font-size: 13px; font-weight: 600; color: var(--tx2); margin-bottom: 5px; }
.input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line2); border-radius: var(--radius-s); background: var(--bg);
  color: var(--tx); font: inherit; outline: none; transition: border-color .15s, box-shadow .15s; min-height: 40px;
}
html[data-theme="light"] .input, html[data-theme="light"] select, html[data-theme="light"] textarea { background: #fff; }
textarea { min-height: 80px; resize: vertical; }
.input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input.num { text-align: right; }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.c12 { grid-column: span 12; } .c8 { grid-column: span 8; } .c6 { grid-column: span 6; } .c4 { grid-column: span 4; } .c3 { grid-column: span 3; } .c2 { grid-column: span 2; }
.hint { font-size: 12.5px; color: var(--tx3); margin-top: 4px; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.form-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.sticky-foot { position: sticky; bottom: 0; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); padding: 12px 0; border-top: 1px solid var(--line); margin-top: 16px; z-index: 10; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--tx2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.tabs a.on { color: var(--accent); border-color: var(--accent); }

/* ---------- Autocomplétion ---------- */
.ac { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--bg2); border: 1px solid var(--line2); border-radius: 10px; box-shadow: var(--shadow); max-height: 300px; overflow: auto; z-index: 70; display: none; min-width: 280px; }
.ac-list.open { display: block; }
.ac-item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.ac-item:last-child { border-bottom: 0; }
.ac-item:hover, .ac-item.sel { background: var(--bg3); }
.ac-item b { display: block; font-weight: 600; }
.ac-item small { color: var(--tx3); }

/* ---------- Éditeur de document ---------- */
.lines { width: 100%; border-collapse: separate; border-spacing: 0; }
.lines th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--tx3); text-align: left; padding: 6px 6px; font-weight: 600; }
.lines td { padding: 4px; vertical-align: top; }
.lines tr.ln td { border-top: 1px solid var(--line); padding-top: 8px; padding-bottom: 8px; }
.lines .input, .lines select, .lines textarea { min-height: 36px; padding: 7px 9px; font-size: 14px; }
.lines textarea { min-height: 36px; height: 36px; resize: vertical; }
.lines .w-ref { width: 130px; } .lines .w-qty { width: 84px; } .lines .w-unit { width: 78px; } .lines .w-pu { width: 112px; }
.lines .w-rem { width: 74px; } .lines .w-tva { width: 84px; } .lines .w-tot { width: 110px; } .lines .w-act { width: 76px; }
.lines .l-tot { padding-top: 15px !important; font-weight: 600; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lines tr.ln-texte textarea { font-style: italic; }
.lines tr.ln-titre .input { font-weight: 700; }
.l-acts { display: flex; gap: 2px; padding-top: 4px; }
.drag { cursor: grab; color: var(--tx3); }
tr.dragging { opacity: .4; }
.add-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.totals { width: 100%; max-width: 380px; margin-left: auto; }
.totals .tr { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-variant-numeric: tabular-nums; }
.totals .tr.big { font-size: 1.25rem; font-weight: 800; border-top: 2px solid var(--line2); margin-top: 6px; padding-top: 10px; }
.totals .tr .input { width: 90px; min-height: 32px; padding: 4px 8px; }

/* ---------- Saisie tableur ---------- */
.sheet-wrap { border: 1px solid var(--line2); border-radius: 10px; background: var(--bg); }
.sheet { border-collapse: collapse; width: 100%; table-layout: fixed; }
.sheet th { background: var(--bg3); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--tx3); font-weight: 600; padding: 8px; text-align: left; border-bottom: 1px solid var(--line2); border-right: 1px solid var(--line); }
.sheet th:first-child { border-top-left-radius: 10px; } .sheet th:last-child { border-top-right-radius: 10px; border-right: 0; }
.sheet th.r { text-align: right; }
.sheet td { padding: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); vertical-align: top; background: var(--bg2); }
.sheet td:last-child { border-right: 0; }
.sheet tr:last-child td { border-bottom: 0; }
.sheet tr:last-child td:first-child { border-bottom-left-radius: 10px; } .sheet tr:last-child td:last-child { border-bottom-right-radius: 10px; }
.sheet .cell { width: 100%; border: 0; background: transparent; color: var(--tx); font: inherit; font-size: 14px; padding: 8px; min-height: 36px; outline: none; border-radius: 0; resize: none; display: block; line-height: 1.4; }
.sheet .cell.num { text-align: right; font-variant-numeric: tabular-nums; }
.sheet textarea.cell { overflow: hidden; }
.sheet select.cell { appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 6px; }
.sheet .cell:focus { box-shadow: inset 0 0 0 2px var(--accent); background: var(--bg); position: relative; z-index: 2; }
.sheet tr.cur td { background: color-mix(in srgb, var(--accent) 7%, var(--bg2)); }
.sheet .c-n { text-align: center; }
.sheet .l-type { width: 100%; border: 0; background: transparent; color: var(--tx3); font: 600 12px var(--font); text-align: center; text-align-last: center; padding: 10px 0; cursor: pointer; appearance: none; -webkit-appearance: none; outline: none; }
.sheet .l-type:focus, .sheet .l-type:hover { color: var(--accent); }
.sheet .w-n { width: 46px; } .sheet .w-ref { width: 150px; } .sheet .w-qty { width: 76px; } .sheet .w-unit { width: 74px; } .sheet .w-pu { width: 104px; }
.sheet .w-rem { width: 70px; } .sheet .w-tva { width: 76px; } .sheet .w-tot { width: 108px; } .sheet .w-act { width: 78px; }
.sheet .l-tot { padding: 9px 8px !important; text-align: right; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sheet .ln-titre .cell { font-weight: 700; }
.sheet .ln-titre td { background: var(--bg3); }
.sheet .ln-texte .cell { font-style: italic; color: var(--tx2); }
.sheet tr.ln-new td { background: var(--bg); }
.sheet tr.ln-new .cell::placeholder { color: var(--tx3); font-style: italic; }
.sheet tr.ln-new .l-acts, .sheet tr.ln-new .c-n .l-type { visibility: hidden; }
.sheet .l-acts { display: flex; align-items: center; justify-content: flex-end; gap: 0; padding: 3px 4px; opacity: .3; transition: opacity .15s; }
.sheet tr:hover .l-acts, .sheet tr.cur .l-acts { opacity: 1; }
.sheet .l-acts .drag { cursor: grab; color: var(--tx3); padding: 0 4px; font-size: 13px; letter-spacing: -2px; }
.sheet .l-del:hover { color: var(--bad); }
.sheet .ac-list { min-width: 420px; }
kbd { display: inline-block; font: 600 11px var(--mono); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line2); border-bottom-width: 2px; background: var(--bg); color: var(--tx2); }
.btn.primary kbd { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.35); color: #fff; }
.kbd-help summary { cursor: pointer; color: var(--tx3); font-size: 13px; }
.kbd-help > div { position: absolute; right: 18px; z-index: 30; background: var(--bg2); border: 1px solid var(--line2); border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow); font-size: 13px; line-height: 2; max-width: 560px; }
.card-h { position: relative; }
.modal-box.wide { max-width: 860px; }
.cat-list { max-height: 55vh; overflow: auto; margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; }
.cat-item { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.cat-item:hover { background: var(--bg3); }
.cat-item:last-child { border-bottom: 0; }
.cat-item .cat-q { width: 70px; min-height: 32px; padding: 4px 8px; }

/* ---------- Bandeau réseau ---------- */
.net-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 84px; z-index: 150; max-width: min(720px, calc(100vw - 24px)); padding: 12px 16px; border-radius: 12px;
  background: var(--bg2); border: 1px solid var(--line2); box-shadow: var(--shadow); font-size: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.net-bar.warn { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--bg2)); }
.net-bar.bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--bg2)); }
.net-bar[hidden] { display: none; }

/* ---------- Sous-totaux ---------- */
.tbl tr.row-st td { font-weight: 700; background: color-mix(in srgb, var(--accent) 7%, transparent); border-top: 1.5px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.sheet .ln-soustotal td { background: color-mix(in srgb, var(--accent) 8%, var(--bg2)); border-top: 1.5px solid color-mix(in srgb, var(--accent) 50%, transparent); }
.sheet .ln-soustotal .cell { font-weight: 700; text-align: right; }
.sheet .ln-soustotal .l-tot { color: var(--accent); }

/* ---------- Calculatrice de rentabilité ---------- */
.calc summary { list-style: none; }
.calc summary::-webkit-details-marker { display: none; }
.calc-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.calc-tbl .input { width: 110px; min-height: 32px; padding: 4px 8px; margin-left: auto; }
.calc-tbl td { padding: 6px 10px; }
.calc-tbl tr.c-missing .input { border-color: var(--warn); }
.calc-sum { max-width: none; }
.calc-sum .tr > span:first-child { display: flex; flex-direction: column; }
.calc-sum .chip { padding: 3px 8px; font-size: 12px; cursor: pointer; }
@media (max-width: 900px) { .calc-grid { grid-template-columns: 1fr; } }

/* ---------- E-mails ---------- */
.mail-body { min-height: 300px; font: 14px/1.55 var(--font); }
.att-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.att { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.att strong { display: block; font-weight: 600; font-size: 14px; }
.att small { display: block; }
.drop { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; text-align: center; padding: 16px; border: 2px dashed var(--line2); border-radius: 10px; cursor: pointer; color: var(--tx2); }
.drop.on, .drop:hover { border-color: var(--accent); color: var(--accent); }
.mbox { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 16px; align-items: start; }
.mbox-folders a { display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 8px; color: var(--tx2); text-decoration: none; font-weight: 500; }
.mbox-folders a:hover { background: var(--bg3); color: var(--tx); }
.mbox-folders a.on { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.mlist a.mrow { display: grid; grid-template-columns: 210px minmax(0, 1fr) auto; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); color: var(--tx); text-decoration: none; align-items: baseline; }
.mlist a.mrow:hover { background: var(--bg3); }
.mlist a.mrow.unread { font-weight: 700; }
.mlist a.mrow.unread .m-from::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 7px; vertical-align: middle; }
.mlist .m-from, .mlist .m-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mlist .m-sub .dim { font-weight: 400; }
.mlist .m-date { color: var(--tx3); font-size: 12.5px; font-weight: 400; white-space: nowrap; }
.mview-frame { width: 100%; min-height: 420px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.mview-text { white-space: pre-wrap; font: 14px/1.55 var(--font); margin: 0; }
@media (max-width: 900px) {
  .mbox { grid-template-columns: 1fr; }
  .mbox-folders { display: flex; gap: 4px; overflow-x: auto; }
  .mbox-folders a { white-space: nowrap; }
  .mlist a.mrow { grid-template-columns: minmax(0, 1fr) auto; }
  .mlist a.mrow .m-sub { grid-column: 1 / -1; }
}

/* ---------- Statistiques (palette validée : bleu / orange) ---------- */
html[data-theme="light"] { --s1: #2a78d6; --s2: #eb6834; --seq1: #cde2fb; --seq2: #9ec5f4; --seq3: #6da7ec; --seq4: #3987e5; --seq5: #256abf; --seq6: #184f95; }
html[data-theme="dark"] { --s1: #3987e5; --s2: #d95926; --seq1: #13243a; --seq2: #163055; --seq3: #184f95; --seq4: #1c5cab; --seq5: #2a78d6; --seq6: #5598e7; }
svg.viz { width: 100%; height: auto; display: block; overflow: visible; }
.viz-wrap { overflow-x: auto; }
@media (max-width: 700px) { svg.viz { min-width: 680px; } }
svg.viz .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
svg.viz .grid.zero { stroke: var(--line2); }
svg.viz .ax { fill: var(--tx3); font-size: 12px; font-family: var(--font); }
svg.viz .s1 { fill: var(--s1); } svg.viz .s2 { fill: var(--s2); }
svg.viz .neg { opacity: .55; }
svg.viz .hz { fill: transparent; }
svg.viz .hit:hover .hz { fill: var(--bg3); }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--tx2); }
.legend i, .viz-tip i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend i.s1, .viz-tip i.s1 { background: var(--s1); } .legend i.s2, .viz-tip i.s2 { background: var(--s2); }
.viz-tip { position: fixed; z-index: 200; background: var(--bg2); border: 1px solid var(--line2); border-radius: 8px; padding: 8px 10px; font-size: 13px; box-shadow: var(--shadow); pointer-events: none; min-width: 160px; }
.viz-tip b { display: block; margin-bottom: 3px; }
.gauge { position: relative; height: 14px; border-radius: 7px; background: var(--bg3); overflow: hidden; }
.gauge span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 7px; }
.gauge .g-proj { background: color-mix(in srgb, var(--s1) 30%, transparent); }
.gauge .g-val { background: var(--s1); }
.gauge .g-val.hot { background: var(--bad); }
.hbars { display: flex; flex-direction: column; gap: 8px; }
.hb { display: grid; grid-template-columns: minmax(0, 120px) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.hb-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--tx2); }
.hb-t { height: 10px; background: var(--bg3); border-radius: 5px; overflow: hidden; }
.hb-b { display: block; height: 100%; background: var(--s1); border-radius: 5px; }
.hb-v { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.pbar { display: inline-block; width: 60px; height: 6px; background: var(--bg3); border-radius: 3px; vertical-align: middle; overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--s1); }
table.heat, table.pivot { border-collapse: separate; border-spacing: 2px; width: 100%; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.heat th, .pivot th { color: var(--tx3); font-weight: 600; text-align: left; padding: 6px 8px; white-space: nowrap; }
.heat td { text-align: center; padding: 8px 4px; border-radius: 5px; background: var(--bg3); color: var(--tx2); min-width: 46px; }
.heat td.h1 { background: var(--seq1); } .heat td.h2 { background: var(--seq2); } .heat td.h3 { background: var(--seq3); color: #fff; }
.heat td.h4 { background: var(--seq4); color: #fff; } .heat td.h5 { background: var(--seq5); color: #fff; } .heat td.h6 { background: var(--seq6); color: #fff; }
html[data-theme="dark"] .heat td.h1, html[data-theme="dark"] .heat td.h2 { color: var(--tx); }
.heat td.ht { background: none; font-weight: 700; color: var(--tx); text-align: right; }
.pivot-wrap { max-height: 70vh; overflow: auto; }
.pivot thead th { position: sticky; top: 0; background: var(--bg2); z-index: 1; text-align: right; }
.pivot thead th:first-child { text-align: left; }
.pivot tbody th { color: var(--tx); font-weight: 500; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.pivot td { padding: 6px 8px; border-radius: 4px; }
.pivot td.p1 { background: color-mix(in srgb, var(--s1) 8%, transparent); } .pivot td.p2 { background: color-mix(in srgb, var(--s1) 16%, transparent); }
.pivot td.p3 { background: color-mix(in srgb, var(--s1) 26%, transparent); } .pivot td.p4 { background: color-mix(in srgb, var(--s1) 38%, transparent); }
.pivot td.p5 { background: color-mix(in srgb, var(--s1) 52%, transparent); }
.pivot td.pt, .pivot tfoot td, .pivot tfoot th { font-weight: 700; color: var(--tx); }
.pivot tfoot td, .pivot tfoot th { border-top: 2px solid var(--line2); }

/* ---------- Vue document ---------- */
.doc-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.doc-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.doc-meta .m-l { font-size: 12px; color: var(--tx3); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.doc-meta .m-v { font-weight: 600; margin-top: 2px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .tl-d { color: var(--tx3); width: 92px; flex: none; font-size: 13px; }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--info-bg); color: var(--tx); border: 1px solid color-mix(in srgb, var(--info) 30%, transparent); font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.notice.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.notice.bad { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.notice .ic { margin-top: 1px; }

/* ---------- Graphique ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.bar .b { width: 100%; max-width: 38px; background: color-mix(in srgb, var(--accent) 75%, transparent); border-radius: 6px 6px 2px 2px; min-height: 2px; position: relative; transition: background .15s; }
.bar .b.prev { background: var(--line2); }
.bar:hover .b { background: var(--accent); }
.bar .bl { font-size: 11px; color: var(--tx3); white-space: nowrap; }
.bar .bv { font-size: 10.5px; color: var(--tx2); white-space: nowrap; opacity: 0; transition: opacity .15s; }
.bar:hover .bv { opacity: 1; }

/* ---------- Thèmes ---------- */
.theme-card { overflow: hidden; }
.theme-thumb { display: block; height: 300px; overflow: hidden; position: relative; background: #d6d9de; border-bottom: 1px solid var(--line); }
.theme-thumb iframe { position: absolute; top: 12px; left: 50%; width: 794px; height: 1123px; border: 0; transform: translateX(-50%) scale(.36); transform-origin: top center; pointer-events: none; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.theme-editor { display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 18px; align-items: start; }
.te-side { position: sticky; top: calc(var(--top-h) + 12px); max-height: calc(100vh - var(--top-h) - 24px); overflow-y: auto; padding-right: 4px; }
.te-side details { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; }
.te-side summary { padding: 11px 14px; font-weight: 600; cursor: pointer; list-style: none; display: flex; justify-content: space-between; }
.te-side summary::after { content: '+'; color: var(--tx3); }
.te-side details[open] summary::after { content: '–'; }
.te-body { padding: 0 14px 14px; }
.te-body .form-grid { gap: 10px; }
.c-color { grid-column: span 6; }
.color-in { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line2); border-radius: 8px; padding: 4px 8px; background: var(--bg); }
.color-in input[type=color] { width: 30px; height: 26px; border: 0; padding: 0; background: none; cursor: pointer; }
.color-in code { font-size: 12px; color: var(--tx2); }
input[type=range].input { padding: 0; min-height: 28px; accent-color: var(--accent); border: 0; background: transparent; box-shadow: none; }
.te-preview { position: sticky; top: calc(var(--top-h) + 12px); }
.te-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.te-frame { background: #525659; border-radius: 12px; overflow: hidden; height: calc(100vh - var(--top-h) - 90px); }
.te-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
@media (max-width: 1100px) {
  .theme-editor { grid-template-columns: 1fr; }
  .te-side, .te-preview { position: static; max-height: none; }
  .te-frame { height: 70vh; }
}

/* ---------- Actions groupées ---------- */
.chk { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.bulk-bar { position: sticky; bottom: 12px; margin-top: 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end;
  background: var(--bg2); border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--line)); border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); z-index: 20; }
.bulk-bar > span { margin-right: auto; }

/* ---------- Divers ---------- */
.flash { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.f-ok { background: var(--ok-bg); color: var(--ok); }
.f-err { background: var(--bad-bg); color: var(--bad); }
.f-info { background: var(--info-bg); color: var(--info); }
.flash-x { background: none; border: 0; color: inherit; font-size: 20px; cursor: pointer; line-height: 1; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; padding: 22px; position: relative; box-shadow: var(--shadow); }
.modal-x { position: absolute; top: 10px; right: 12px; background: none; border: 0; color: var(--tx2); font-size: 24px; cursor: pointer; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: center; }
.list-plain li:last-child { border-bottom: 0; }
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); color: var(--tx2); text-decoration: none; }
.pagination .on { background: var(--accent); border-color: var(--accent); color: #fff; }
.copy-field { display: flex; gap: 6px; }
.copy-field .input { font-family: var(--mono); font-size: 12.5px; }
.margin-ok { color: var(--ok); } .margin-bad { color: var(--bad); }
.av { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); flex: none; font-size: 14px; }

/* ---------- Connexion / installation ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background:
  radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 60%), var(--bg); }
.auth-box { width: 100%; max-width: 400px; }
.auth-box .card { padding: 28px; }
.auth-logo { display: flex; gap: 12px; align-items: center; justify-content: center; margin-bottom: 22px; }
.auth-logo .logo-mark { width: 44px; height: 44px; font-size: 17px; border-radius: 12px; }
.auth-logo strong { font-size: 1.4rem; }
.steps { display: flex; gap: 6px; margin-bottom: 20px; }
.steps span { flex: 1; height: 4px; border-radius: 4px; background: var(--line2); }
.steps span.on { background: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .side { transform: translateX(-100%); box-shadow: var(--shadow); }
  body.nav-open .side { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 35; }
  .main { margin-left: 0; }
  .only-m { display: inline-grid !important; }
  .top { padding: 0 12px; gap: 8px; }
  .content { padding: 16px 14px 96px; }
  .g3 { grid-template-columns: 1fr; }
  .g2 { grid-template-columns: 1fr; }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--bg2); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; align-items: center;
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--tx3); font-size: 11px; text-decoration: none; padding: 4px 8px; min-width: 56px; }
  .tabbar a:hover { color: var(--tx); }
  .tabbar .tab-plus { background: var(--accent); color: #fff; width: 50px; height: 50px; border-radius: 16px; padding: 0; justify-content: center; min-width: 0; margin-top: -18px; box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 45%, transparent); }
  .c8, .c6, .c4, .c3 { grid-column: span 12; }
  .c2 { grid-column: span 6; }
  .hide-s { display: none; }
  .top-actions .btn.primary { padding: 8px 10px; }
  .sticky-foot { bottom: 64px; }

  /* tableaux -> cartes */
  table.resp thead { display: none; }
  table.resp, table.resp tbody, table.resp tr, table.resp td { display: block; width: 100%; }
  table.resp tr { padding: 12px 14px; border-bottom: 1px solid var(--line); position: relative; }
  table.resp tbody tr.click:hover td { background: none; }
  table.resp tbody tr.click:hover { background: var(--bg3); }
  table.resp td { border: 0; padding: 2px 0; text-align: left !important; }
  table.resp td[data-l]::before { content: attr(data-l) " : "; color: var(--tx3); font-size: 12.5px; }
  table.resp td.rc-amount { position: absolute; right: 14px; top: 12px; width: auto; font-weight: 700; }
  table.resp td.rc-amount::before { content: none; }
  table.resp td.rc-hide { display: none; }
  table.resp td.rc-chk { position: absolute; left: auto; right: 14px; bottom: 12px; width: auto; }
  table.resp tfoot tr { display: flex; justify-content: space-between; }
  table.resp tfoot td { width: auto; }

  /* éditeur de lignes -> cartes */
  .lines thead { display: none; }
  .lines, .lines tbody { display: block; }
  .lines tr.ln { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; padding: 12px 0; border-top: 1px solid var(--line); }
  .lines tr.ln td { border: 0; padding: 0; display: block; width: auto !important; }
  .lines td.c-ref { grid-column: span 2; } .lines td.c-des { grid-column: span 6; order: -1; }
  .lines td.c-qty { grid-column: span 2; } .lines td.c-unit { grid-column: span 2; } .lines td.c-pu { grid-column: span 2; }
  .lines td.c-rem { grid-column: span 2; } .lines td.c-tva { grid-column: span 2; } .lines td.c-tot { grid-column: span 2; }
  .lines td.c-act { grid-column: span 5; }
  .lines td.c-n { grid-column: span 1; order: 10; }
  .sheet-wrap { border: 0; background: transparent; }
  .sheet, .sheet tbody { display: block; }
  .sheet td, .sheet tr.cur td, .sheet tr.ln-new td, .sheet .ln-titre td { border: 0 !important; background: transparent; }
  .sheet .cell { border: 1px solid var(--line2); border-radius: 8px; background: var(--bg); }
  .sheet tr.ln { border-top: 1px solid var(--line); }
  .sheet .l-acts { opacity: 1; }
  .sheet .ac-list { min-width: 0; }
  .lines td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; color: var(--tx3); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
  .lines tr.ln-texte td.c-des, .lines tr.ln-titre td.c-des { grid-column: span 6; }
  .l-acts { justify-content: flex-end; }
  .lines .l-tot { padding-top: 8px !important; text-align: left; }
}
@media (max-width: 560px) {
  .g4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi .k-v { font-size: 1.2rem; }
  h1 { font-size: 1.3rem; }
  .gsearch input::placeholder { color: transparent; }
  .page-h .actions .btn span.lbl { display: none; }
}
@media print {
  .side, .top, .tabbar, .no-print { display: none !important; }
  .main { margin: 0; }
}

/* ---------- v1.5 : saisie mobile, visionneuse PDF, paiements ---------- */
.only-m-b { display: none !important; }
.m-lines { display: none; }
form.is-m .sheet-wrap { display: none; }
form.is-m .m-lines { display: block; }
.m-ln { display: flex; width: 100%; gap: 12px; align-items: flex-start; text-align: left; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; color: var(--tx); font: inherit; cursor: pointer; }
.m-ln:active { background: var(--bg3); }
.m-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.m-main { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; flex: 1; min-width: 0; }
.m-desc { color: var(--tx3); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.m-sub { color: var(--tx2); font-size: 13px; }
.m-rem { color: var(--warn, #b45309); font-weight: 600; }
.m-tot { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.m-tot.m-zero { color: var(--ok); }
.m-go { color: var(--tx3); font-size: 20px; line-height: 1; }
.m-tx .m-main { font-weight: 400; font-style: italic; color: var(--tx2); -webkit-line-clamp: 3; white-space: pre-line; }
.m-ti { background: var(--bg3); } .m-ti .m-main { text-transform: uppercase; letter-spacing: .03em; font-size: 13px; }
.m-st { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 8%, var(--bg2)); }
.m-st .m-main { text-align: right; } .m-st .m-tot { color: var(--accent); }
.m-empty { text-align: center; color: var(--tx3); padding: 26px 10px; border: 1.5px dashed var(--line2); border-radius: 12px; line-height: 1.6; }
.seg { display: flex; background: var(--bg3); border-radius: 10px; padding: 3px; gap: 3px; margin-bottom: 14px; }
.seg button { flex: 1; border: 0; background: none; color: var(--tx2); font: 600 13px var(--font); padding: 8px 4px; border-radius: 8px; cursor: pointer; }
.seg button.on { background: var(--bg2); color: var(--tx); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.seg-radio { display: flex; gap: 8px; }
.seg-radio label { flex: 1; display: flex; align-items: center; gap: 6px; border: 1px solid var(--line2); border-radius: 10px; padding: 9px 12px; cursor: pointer; }
.seg-radio label:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.m-form .f { margin-bottom: 10px; display: block; }
.m-form .f > span:first-child { display: block; font-size: 12.5px; color: var(--tx3); margin-bottom: 4px; }
.m-form textarea.input { width: 100%; resize: vertical; min-height: 70px; }
.m-form #mSearch { margin-bottom: 12px; }
.m-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.m-row select { width: 100%; }
.stepper { display: flex; align-items: stretch; }
.stepper button { width: 42px; border: 1px solid var(--line2); background: var(--bg3); color: var(--tx); font-size: 20px; cursor: pointer; }
.stepper button:first-child { border-radius: 10px 0 0 10px; } .stepper button:last-child { border-radius: 0 10px 10px 0; }
.stepper .input { border-radius: 0; text-align: center; min-width: 0; flex: 1; border-left: 0; border-right: 0; }
.m-chips { display: flex; gap: 8px; margin: 2px 0 12px; flex-wrap: wrap; } .m-chips .chip { cursor: pointer; }
.m-total { display: flex; justify-content: space-between; align-items: baseline; background: var(--bg3); border-radius: 10px; padding: 12px 14px; font-size: 15px; }
.m-total strong { font-size: 18px; }
.m-foot { display: flex; gap: 8px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.m-foot .btn-icon { width: 40px; height: 40px; border: 1px solid var(--line2); border-radius: 10px; background: var(--bg3); color: var(--tx); font-size: 16px; cursor: pointer; }
.m-foot .btn-icon.bad { color: var(--bad); }
.m-foot .grow { flex: 1; }
details.more > summary { cursor: pointer; color: var(--tx2); font-size: 13.5px; padding: 4px 0; }
.mt-s { margin-top: 6px; } textarea.mt-s { width: 100%; } .mb-s { margin-bottom: 6px; }
.foot-total { align-items: baseline; gap: 6px; } .foot-total small { color: var(--tx3); } .foot-total strong { font-size: 17px; }
@media (max-width: 900px) {
  .only-m-b { display: inline-flex !important; }
  .modal-box.m-sheet { max-width: none; border-radius: 18px 18px 0 0; position: fixed; left: 0; right: 0; bottom: 0; max-height: 94vh; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); animation: msheet .18s ease-out; }
  .add-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .add-bar .btn { justify-content: center; }
  .add-bar .btn.primary { grid-column: span 2; padding: 12px; font-size: 15px; }
  .sticky-foot .actions { flex-wrap: nowrap; }
  .sticky-foot .actions .btn { padding: 10px 12px; font-size: 14px; }
  body.modal-open { overflow: hidden; }
  .m-form .input, .m-form select, .m-form textarea { font-size: 16px; } /* évite le zoom automatique sur iPhone */
}
@keyframes msheet { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }

/* Visionneuse PDF */
.pdfv { position: fixed; inset: 0; z-index: 120; background: #3a3d41; display: flex; flex-direction: column; }
.pdfv[hidden] { display: none; }
.pdfv-bar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top)); background: #26282b; color: #e5e7eb; flex-wrap: wrap; }
.pdfv-bar .t { flex: 1; min-width: 120px; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pdfv-bar button, .pdfv-bar a { background: #3f4246; color: #fff; border: 0; border-radius: 8px; padding: 8px 12px; font: 600 13.5px var(--font); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.pdfv-bar .pri { background: var(--accent); }
.pdfv-bar .x { font-size: 18px; padding: 6px 12px; }
.pdfv-body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 16px 8px 40px; text-align: center; touch-action: pan-x pan-y pinch-zoom; }
.pdfv-body canvas { display: block; margin: 0 auto 14px; background: #fff; box-shadow: 0 4px 18px rgba(0,0,0,.35); max-width: none; }
.pdfv-msg { color: #e5e7eb; padding: 40px 16px; font-size: 15px; }
.pdfv-spin { width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; margin: 0 auto 14px; animation: pspin .8s linear infinite; }
@keyframes pspin { to { transform: rotate(360deg); } }
.pdfv-zoom { display: inline-flex; gap: 2px; }
@media (max-width: 600px) { .pdfv-bar .lbl { display: none; } .pdfv-body { padding: 10px 0 30px; } }
.calc-grid > * { min-width: 0; }
@media (max-width: 900px) {
  .calc-tbl thead { display: none; }
  .calc-tbl, .calc-tbl tbody { display: block; width: 100%; }
  .calc-tbl tr { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .calc-tbl td { display: block; border: 0 !important; padding: 0 !important; }
  .calc-tbl td:first-child { grid-column: 1 / -1; }
  .calc-tbl td.c-q::before { content: "× "; color: var(--tx3); }
  .calc-tbl td.c-q { order: 2; } .calc-tbl td:nth-child(3) { order: 1; } .calc-tbl td.c-t { order: 3; min-width: 84px; text-align: right; }
  .calc-tbl .input.c-cost { width: 120px; font-size: 16px; }
  .calc-sum .tr { flex-wrap: wrap; gap: 4px; }
  .calc-sum .tr > span:first-child { min-width: 0; }
  .sticky-foot .row.between { gap: 8px; flex-wrap: nowrap; }
  .sticky-foot .actions { flex-shrink: 1; min-width: 0; }
}
@media (max-width: 900px) {
  .sticky-foot { bottom: calc(64px + env(safe-area-inset-bottom)); }
  /* Pendant la saisie d'un document : pas de barre d'onglets, boutons d'enregistrement toujours visibles */
  body:has(#docForm) .tabbar, body:has(#mailForm) .tabbar { display: none; }
  body:has(#docForm) .sticky-foot, body:has(#mailForm) .sticky-foot { bottom: 0; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  body:has(#docForm) .content { padding-bottom: 24px; }
}
@media (max-width: 900px) {
  .sticky-foot .row.between { flex-wrap: wrap; }
  .sticky-foot .actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; width: 100%; margin-left: 0 !important; }
  .sticky-foot .actions .btn { white-space: normal; line-height: 1.15; justify-content: center; text-align: center; min-height: 44px; padding: 8px 10px; }
  .sticky-foot .foot-total { width: 100%; justify-content: space-between; }
  .sticky-foot #fxState, .sticky-foot #sendState { width: 100%; }
}
.m-form .ac { position: relative; z-index: 20; } .m-form .ac .ac-list { min-width: 0; max-height: 45vh; }
.grid > * { min-width: 0; }
label.f > span.stepper, label.f > span.row { display: flex; font-weight: 400; margin-bottom: 0; color: inherit; font-size: inherit; }
.nas-ask { position: fixed; z-index: 160; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom)); width: min(520px, calc(100vw - 24px)); background: var(--bg2); color: var(--tx); border: 1px solid var(--line2); border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.35); padding: 14px 16px; display: flex; gap: 12px; align-items: center; animation: msheet .2s ease-out; }
.nas-ask .nas-btns { display: flex; gap: 6px; flex: none; }
.nas-ask .dim { word-break: break-all; }
@media (max-width: 600px) { .nas-ask { flex-direction: column; align-items: stretch; bottom: calc(76px + env(safe-area-inset-bottom)); } .nas-ask .nas-btns .btn { flex: 1; justify-content: center; } }
/* Mode discret */
#privBtn .i-eyeoff { display: none; }
body.privacy #privBtn .i-eye { display: none; } body.privacy #privBtn .i-eyeoff { display: inline; }
body.privacy #privBtn { color: var(--accent); }
body.privacy .amt:not(.peek), body.privacy svg.viz, body.privacy .viz-wrap svg, body.privacy .bars .b, body.privacy .gauge, body.privacy .heat td, body.privacy .kpi .k-v { filter: blur(7px); transition: filter .2s; }
body.privacy .amt { cursor: pointer; }
.amt { white-space: nowrap; }
.urs-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.urs-box { border: 1px solid var(--line2); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.urs-box.zero { opacity: .6; }
.urs-box .u-l { font-size: 12.5px; color: var(--tx2); font-weight: 600; }
.urs-box .u-v { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.urs-box .u-c { font-size: 12px; color: var(--tx3); }
.urs-box .btn { align-self: flex-start; }
.list-plain li.on { background: color-mix(in srgb, var(--accent) 8%, transparent); border-radius: 8px; padding-left: 8px; padding-right: 8px; }
body.privacy .urs-box .u-v { filter: blur(8px); }
@media (max-width: 700px) { .urs-grid { grid-template-columns: 1fr; } }
