/* SYSFLASH Facturation — interface */
:root {
  --bg: #f5f5f7; --surface: rgba(255,255,255,.82); --solid: #fff; --line: rgba(0,0,0,.08); --line2: rgba(0,0,0,.14);
  --text: #1d1d1f; --muted: #6e6e73; --faint: #a1a1a6; --fill: rgba(118,118,128,.1); --fill2: rgba(118,118,128,.18);
  --accent: #0071e3; --accent-h: #0077ed; --accent-soft: rgba(0,113,227,.1);
  --ok: #248a3d; --ok-soft: rgba(52,199,89,.16); --warn: #b25000; --warn-soft: rgba(255,159,10,.18); --err: #d70015; --err-soft: rgba(255,59,48,.13);
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 28px rgba(0,0,0,.06); --r: 18px; --r-s: 11px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #000; --surface: rgba(28,28,30,.78); --solid: #1c1c1e; --line: rgba(255,255,255,.1); --line2: rgba(255,255,255,.18);
  --text: #f5f5f7; --muted: #98989d; --faint: #636366; --fill: rgba(118,118,128,.2); --fill2: rgba(118,118,128,.32);
  --accent: #0a84ff; --accent-h: #409cff; --accent-soft: rgba(10,132,255,.18);
  --ok: #30d158; --ok-soft: rgba(48,209,88,.16); --warn: #ff9f0a; --warn-soft: rgba(255,159,10,.16); --err: #ff453a; --err-soft: rgba(255,69,58,.16);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.5); color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #000; --surface: rgba(28,28,30,.78); --solid: #1c1c1e; --line: rgba(255,255,255,.1); --line2: rgba(255,255,255,.18);
  --text: #f5f5f7; --muted: #98989d; --faint: #636366; --fill: rgba(118,118,128,.2); --fill2: rgba(118,118,128,.32);
  --accent: #0a84ff; --accent-h: #409cff; --accent-soft: rgba(10,132,255,.18);
  --ok: #30d158; --ok-soft: rgba(48,209,88,.16); --warn: #ff9f0a; --warn-soft: rgba(255,159,10,.16); --err: #ff453a; --err-soft: rgba(255,69,58,.16);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.5); color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.47 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; letter-spacing: -.01em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 32px; line-height: 1.1; letter-spacing: -.03em; font-weight: 700; margin: 0; text-wrap: balance; }
h2 { font-size: 19px; letter-spacing: -.02em; font-weight: 650; margin: 0 0 14px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 6px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.ic { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; border-radius: 8px; }

/* Structure */
.app { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 12px; background: var(--surface); backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 16px; font-weight: 700; letter-spacing: -.02em; font-size: 16px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .mark { width: 36px; height: 36px; border-radius: 10px; box-shadow: 0 2px 8px rgba(16,63,167,.25); flex: none; }
.authlogo { display: block; width: min(250px, 70%); height: auto; margin: 0 auto 22px; position: relative; z-index: 1; }
.brand small { display: block; font-weight: 500; font-size: 11.5px; color: var(--muted); letter-spacing: 0; }
.nav-label { font-size: 11.5px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; padding: 14px 12px 5px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; color: var(--text); font-weight: 500; font-size: 14.5px; }
.nav a:hover { background: var(--fill); text-decoration: none; }
.nav a.on { background: var(--accent); color: #fff; box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 35%, transparent); }
.nav a .ic { opacity: .85; }
.nav a .badge { margin-left: auto; background: var(--err); color: #fff; font-size: 11.5px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; padding: 0 6px; }
.nav a.on .badge { background: #fff; color: var(--accent); }
.diff { display: grid; grid-template-columns: 170px 1fr 1fr; gap: 6px 14px; font-size: 14px; margin: 10px 0; }
.diff .old { color: var(--muted); text-decoration: line-through; } .diff .new { font-weight: 600; }
.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.me { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(145deg, #a0a4ad, #6b6f78); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }
.me b { display: block; font-size: 13.5px; line-height: 1.2; } .me span { font-size: 12px; color: var(--muted); }
.main { padding: 30px clamp(18px, 4vw, 48px) 60px; max-width: 1280px; width: 100%; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.head .sub { color: var(--muted); margin-top: 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn.burger { display: none; }

/* Composants */
.card { background: var(--solid); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.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)); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 16px; border-radius: 980px; border: 0; font: 500 14.5px var(--font); letter-spacing: -.01em; cursor: pointer; background: var(--fill); color: var(--text); transition: background .15s, transform .1s; white-space: nowrap; }
.btn:hover { background: var(--fill2); text-decoration: none; } .btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: #fff; } .btn.primary:hover { background: var(--accent-h); }
.btn.danger { color: var(--err); } .btn.danger:hover { background: var(--err-soft); }
.btn.big { height: 46px; font-size: 16px; padding: 0 24px; width: 100%; }
.btn.sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }
label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], input[type=tel], input[type=file], select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--r-s); border: 1px solid var(--line2); background: var(--solid); color: var(--text); font: 15px var(--font); transition: border-color .15s, box-shadow .15s; }
textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.45; }
input[type=file] { padding: 8px 12px; height: auto; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
input[type=color] { width: 48px; height: 40px; padding: 3px; border-radius: var(--r-s); border: 1px solid var(--line2); background: var(--solid); }
.field { margin-bottom: 14px; }
.check { display: flex; gap: 9px; align-items: center; font-size: 14.5px; color: var(--text); font-weight: 400; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.search { position: relative; } .search .ic { position: absolute; left: 12px; top: 11px; color: var(--faint); } .search input { padding-left: 36px; border-radius: 980px; background: var(--fill); border-color: transparent; min-width: 240px; }
.tablewrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover { background: var(--fill); }
table.t th.num { text-align: right; }
table.t td a.strong { font-weight: 600; color: var(--text); }
.clip { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 980px; font-size: 12.5px; font-weight: 600; background: var(--fill); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.err { background: var(--err-soft); color: var(--err); } .pill.blue { background: var(--accent-soft); color: var(--accent); }
.flash { padding: 12px 16px; border-radius: 14px; margin-bottom: 16px; font-weight: 500; background: var(--ok-soft); color: var(--ok); }
.flash.err { background: var(--err-soft); color: var(--err); } .flash.warn { background: var(--warn-soft); color: var(--warn); }
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty .ic { width: 40px; height: 40px; color: var(--faint); margin-bottom: 10px; }
.kpi .v { font-size: 27px; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 13px; color: var(--muted); font-weight: 500; } .kpi .d { font-size: 13px; color: var(--muted); margin-top: 4px; }
.kpi { margin: 0; }
.seg { display: inline-flex; background: var(--fill); border-radius: 10px; padding: 2px; }
.seg a { padding: 5px 14px; border-radius: 8px; font-size: 13.5px; font-weight: 500; color: var(--text); }
.seg a:hover { text-decoration: none; } .seg a.on { background: var(--solid); box-shadow: 0 1px 4px rgba(0,0,0,.14); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; padding-bottom: 0; } .row:first-child { padding-top: 0; }
.tile { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: #fff; flex: none; }
.tile .ic { width: 22px; height: 22px; }
.tile.blue { background: linear-gradient(145deg, #40a9ff, #0064d9); } .tile.green { background: linear-gradient(145deg, #5fdc7d, #1f9d3f); } .tile.orange { background: linear-gradient(145deg, #ffb340, #f06a00); } .tile.gray { background: linear-gradient(145deg, #a6aab3, #6b6f78); } .tile.purple { background: linear-gradient(145deg, #c58bff, #7a3ff0); }
.codebox { font: 600 15px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--fill); border-radius: 12px; padding: 14px; letter-spacing: .04em; word-break: break-all; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 20px; }
dialog { border: 0; border-radius: 22px; padding: 26px; background: var(--solid); color: var(--text); box-shadow: 0 30px 80px rgba(0,0,0,.35); width: min(460px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.4); backdrop-filter: blur(6px); }
.pager { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 16px; }

/* Éditeur de document */
.lines td { padding: 8px 6px !important; vertical-align: top !important; }
.lines td:first-child { padding-left: 16px !important; } .lines input, .lines textarea { font-size: 14px; }
.lines .n { width: 110px; } .lines .q { width: 84px; } .lines .x { width: 74px; } .lines input.num { text-align: right; }
.totals { margin-left: auto; width: min(360px, 100%); }
.totals div { display: flex; justify-content: space-between; padding: 6px 0; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 20px; font-weight: 700; border-top: 1px solid var(--line2); margin-top: 6px; padding-top: 12px; letter-spacing: -.02em; }
.pdfframe { width: 100%; height: 900px; border: 0; background: #525659; display: block; }
.chart { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; align-items: end; height: 180px; padding-top: 10px; }
.chart .b { background: linear-gradient(180deg, #4db2ff, var(--accent)); border-radius: 6px 6px 2px 2px; min-height: 3px; position: relative; }
.chart .b.zero { background: var(--fill2); }
.chart .col { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 6px; text-align: center; font-size: 11.5px; color: var(--muted); }

/* Signatures */
.sigpad { position: relative; height: 230px; border-radius: 18px; background:
    radial-gradient(120% 140% at 0% 0%, rgba(10,132,255,.10), transparent 55%), radial-gradient(120% 140% at 100% 100%, rgba(106,53,255,.10), transparent 55%), #fbfbfd;
  border: 1px solid var(--line2); box-shadow: inset 0 1px 0 #fff, 0 10px 30px rgba(16,63,167,.08); overflow: hidden; touch-action: none; cursor: crosshair; }
.sigpad::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(16,63,167,.13) 1px, transparent 1px); background-size: 18px 18px; pointer-events: none; }
.sigpad.active { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), 0 10px 30px rgba(16,63,167,.12); }
.sigpad canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.sigpad-line { position: absolute; left: 9%; right: 9%; bottom: 26%; height: 1.5px; background: linear-gradient(90deg, transparent, rgba(16,63,167,.45), transparent); pointer-events: none; }
.sigpad-hint { position: absolute; left: 0; right: 0; bottom: 11%; text-align: center; font-size: 12.5px; letter-spacing: .14em; text-transform: uppercase; color: #8a93a6; pointer-events: none; transition: opacity .2s; }
.sigpad.has-ink .sigpad-hint { opacity: 0; }
.ink { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--solid); background: var(--c); box-shadow: 0 0 0 1px var(--line2); cursor: pointer; padding: 0; }
.ink.on { box-shadow: 0 0 0 2px var(--accent); }
.sigthumb { display: grid; place-items: center; width: 120px; height: 56px; padding: 6px; border-radius: 12px; background: #fff; border: 1px solid var(--line2); flex: none; }
.sigthumb.big { width: 170px; height: 76px; }
.sigthumb img, .sigpreview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.sigpreview { height: 150px; display: grid; place-items: center; border-radius: 14px; background: #fff; border: 1px dashed var(--line2); margin-bottom: 12px; padding: 10px; }

/* Authentification */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #05060a; color: #f5f5f7; overflow-x: hidden; color-scheme: dark;
  --text: #f5f5f7; --muted: #a1a1a6; --solid: rgba(255,255,255,.07); --line2: rgba(255,255,255,.16); --fill: rgba(255,255,255,.1); --fill2: rgba(255,255,255,.17); --accent: #0a84ff; --accent-h: #409cff; --accent-soft: rgba(10,132,255,.25); --line: rgba(255,255,255,.12); }
.aurora { position: fixed; inset: -20%; z-index: 0; filter: blur(70px) saturate(140%); opacity: .75; pointer-events: none; }
.aurora i { position: absolute; border-radius: 50%; animation: drift 22s ease-in-out infinite alternate; }
.aurora i:nth-child(1) { width: 46vw; height: 46vw; left: 6%; top: 4%; background: #0a5cff; }
.aurora i:nth-child(2) { width: 38vw; height: 38vw; right: 4%; top: 22%; background: #00c2ff; animation-duration: 28s; animation-delay: -6s; }
.aurora i:nth-child(3) { width: 34vw; height: 34vw; left: 30%; bottom: 0; background: #6a35ff; animation-duration: 34s; animation-delay: -12s; }
@keyframes drift { to { transform: translate3d(9vw, -7vh, 0) scale(1.18); } }
.glass { position: relative; z-index: 1; width: min(420px, 100%); padding: 38px 34px 30px; border-radius: 30px; background: rgba(22,24,32,.55); backdrop-filter: blur(40px) saturate(180%); -webkit-backdrop-filter: blur(40px) saturate(180%); border: 1px solid rgba(255,255,255,.14); box-shadow: 0 40px 100px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.12); text-align: center; }
.glass h1 { font-size: 26px; margin-bottom: 6px; } .glass .muted { margin-bottom: 24px; }
.glass form { text-align: left; } .glass input { background: rgba(255,255,255,.07); height: 46px; border-radius: 13px; }
.faceid { width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 22px; display: grid; place-items: center; background: linear-gradient(145deg, rgba(255,255,255,.16), rgba(255,255,255,.04)); border: 1px solid rgba(255,255,255,.18); color: #6cc4ff; position: relative; overflow: hidden; }
.faceid .ic { width: 44px; height: 44px; stroke-width: 1.4; }
.faceid::after { content: ""; position: absolute; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, transparent, #6cc4ff, transparent); box-shadow: 0 0 14px #37a8ff; animation: scan 2.6s ease-in-out infinite; }
@keyframes scan { 0%, 100% { top: 12%; opacity: 0; } 15%, 85% { opacity: 1; } 50% { top: 86%; } }
.btn.bio { background: #fff; color: #000; } .btn.bio:hover { background: #e8e8ed; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 18px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: rgba(255,255,255,.14); }
.otp { font-size: 26px !important; letter-spacing: .45em; text-align: center; font-variant-numeric: tabular-nums; height: 58px !important; }
.methods { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.methods a { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 13px; background: rgba(255,255,255,.07); color: #f5f5f7; font-size: 14.5px; font-weight: 500; text-align: left; }
.methods a:hover { background: rgba(255,255,255,.13); text-decoration: none; }
.authfoot { position: relative; z-index: 1; margin-top: 22px; font-size: 12.5px; color: rgba(255,255,255,.5); text-align: center; }
.auth .flash { text-align: left; font-size: 14px; }
.wrapauth { width: min(420px, 100%); }
body.auth dialog { background: #1c1c1e; color: #f5f5f7; border: 1px solid rgba(255,255,255,.14); }

/* Application installée : zones sûres (encoche, barre d'accueil) et confort tactile */
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent; }
@media (display-mode: standalone) { .main { padding-bottom: calc(84px + env(safe-area-inset-bottom)); } a, button { -webkit-touch-callout: none; } }
@media (max-width: 900px) {
  .btn { min-height: 40px; } .btn.sm { min-height: 34px; }
  input, select, textarea { font-size: 16px !important; } /* évite le zoom automatique d'iOS à la saisie */
  .btn.burger { bottom: calc(16px + env(safe-area-inset-bottom)); }
  .head .actions { width: 100%; } .totals { width: 100%; }
  .glass { padding: 30px 22px 24px; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; width: 264px; transform: translateX(-105%); transition: transform .25s ease; box-shadow: 0 0 60px rgba(0,0,0,.3); }
  .side.open { transform: none; }
  .btn.burger { display: inline-flex; position: fixed; right: 14px; bottom: 16px; z-index: 40; width: 50px; height: 50px; padding: 0; background: var(--accent); color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  h1 { font-size: 26px; } .main { padding-top: 20px; } .search input { min-width: 0; }
  .pdfframe { height: 560px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print { .side, .burger, .actions { display: none; } .app { display: block; } }
