/* Espace pigistes — sobre, beaucoup de blanc, une seule couleur d'accent. */
:root {
  --accent: #004eff;
  --accent-hover: #0042d6;
  --accent-soft: #eef3ff;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --bg: #f5f5f7;
  --card: #ffffff;
  --line: #e5e5ea;
  --line-2: #d2d2d7;
  --green: #1d8a3a;
  --green-soft: #e8f6ec;
  --red: #d70015;
  --red-soft: #fdecee;
  --orange: #b25000;
  --orange-soft: #fff3e3;
  --radius: 18px;
  --radius-s: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 28px rgba(0,0,0,.06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.47 var(--font); letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: -.022em; }
h1 { font-size: 30px; font-weight: 700; }
h2 { font-size: 21px; font-weight: 650; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; color: var(--text-3); }

/* ── Barre du haut ─────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.8); backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0,0,0,.06);
}
.topbar-in {
  max-width: 980px; margin: 0 auto; padding: 0 16px; height: 52px;
  display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 15px; color: var(--text); }
.brand img { width: 24px; height: 24px; border-radius: 6px; }
.brand span { color: var(--text-3); font-weight: 500; }
.spacer { flex: 1; }
@media (max-width: 560px) { .who { display: none; } .hide-s { display: none; } }
.who { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }

.wrap { max-width: 980px; margin: 0 auto; padding: 28px 16px 80px; }
.head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.head .spacer { min-width: 0; }

/* ── Onglets segmentés ─────────────────────────────────────── */
.seg {
  display: inline-flex; background: #e8e8ed; border-radius: 10px; padding: 2px; gap: 2px;
  max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 500;
  color: var(--text); padding: 6px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.seg button.on { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg .count { color: var(--text-3); margin-left: 4px; font-variant-numeric: tabular-nums; }

/* ── Boutons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 15px; font-weight: 500; line-height: 1;
  border: 0; border-radius: 980px; padding: 11px 20px; cursor: pointer;
  background: var(--accent); color: #fff; transition: background .15s, opacity .15s;
  text-decoration: none !important; white-space: nowrap;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.ghost { background: transparent; color: var(--accent); padding: 8px 10px; }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.soft { background: #e8e8ed; color: var(--text); }
.btn.soft:hover { background: #dcdce1; }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.danger:hover { background: #fadadd; }
.btn.small { font-size: 13px; padding: 7px 13px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ── Cartes, listes ────────────────────────────────────────── */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 24px; }
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 14px; padding: 15px 20px;
  border-top: 1px solid var(--line); cursor: pointer; transition: background .1s;
}
.row:first-child { border-top: 0; }
.row:hover { background: #fafafc; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.row .amount { font-variant-numeric: tabular-nums; font-weight: 550; white-space: nowrap; }
.row .chev { color: var(--line-2); font-size: 20px; line-height: 1; }
.empty-state { padding: 48px 24px; text-align: center; color: var(--text-2); }
.empty-state h3 { color: var(--text); margin-bottom: 6px; }

.pill {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px;
  border-radius: 980px; background: #eeeef0; color: var(--text-2); white-space: nowrap;
}
.pill.submitted { background: var(--orange-soft); color: var(--orange); }
.pill.validated { background: var(--green-soft); color: var(--green); }
.pill.rejected { background: var(--red-soft); color: var(--red); }
.pill.paid { background: var(--accent-soft); color: var(--accent); }
.pill.off { background: #eeeef0; color: var(--text-3); }

.banner {
  display: flex; gap: 12px; align-items: center; padding: 14px 18px; border-radius: var(--radius-s);
  background: var(--accent-soft); color: #0a2a78; font-size: 14px; margin-bottom: 18px;
}
.banner.warn { background: var(--orange-soft); color: #6b3300; }
.banner.err { background: var(--red-soft); color: #7a0010; }
.banner .spacer { flex: 1; }
@media (max-width: 560px) { .who { display: none; } .hide-s { display: none; } }

/* ── Formulaires ───────────────────────────────────────────── */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.field > span em { font-style: normal; color: var(--text-3); font-weight: 400; }
input[type=text], input[type=email], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text);
  background: #fff; border: 1px solid var(--line-2); border-radius: var(--radius-s);
  padding: 11px 14px; outline: none; transition: border .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236e6e73' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0,78,255,.12); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 36px; }
.input-suffix::after { content: "€"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.check { display: flex; gap: 10px; align-items: center; font-size: 14px; margin-bottom: 16px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 1.5px dashed var(--line-2); border-radius: var(--radius-s); padding: 22px 16px; text-align: center;
  color: var(--text-2); font-size: 14px; cursor: pointer; transition: border .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { color: var(--accent); font-weight: 550; }
.drop.has { border-style: solid; border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.drop input { display: none; }
.or { text-align: center; font-size: 13px; color: var(--text-3); margin: 10px 0; }

/* ── Feuille modale ────────────────────────────────────────── */
.sheet-bg {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.28);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease;
}
@media (min-width: 700px) { .sheet-bg { align-items: center; padding: 24px; } }
.sheet {
  background: #fff; width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 26px 22px 28px; animation: up .22s cubic-bezier(.2,.8,.2,1);
}
.sheet.wide { max-width: 860px; }
@media (min-width: 700px) { .sheet { border-radius: 20px; padding: 30px 32px; } }
.sheet-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
.sheet-head h2 { flex: 1; }
.x {
  width: 30px; height: 30px; border-radius: 50%; border: 0; background: #e8e8ed; color: var(--text-2);
  font-size: 18px; line-height: 30px; cursor: pointer; flex: none;
}
.x:hover { background: #dcdce1; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; font-size: 14px; margin-bottom: 18px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; }
.quote {
  background: var(--red-soft); color: #5c0010; border-radius: var(--radius-s); padding: 12px 16px;
  font-size: 14px; margin-bottom: 18px; white-space: pre-wrap;
}
.quote.ok { background: var(--green-soft); color: #0d4a1f; }
.reader {
  border: 1px solid var(--line); border-radius: var(--radius-s); padding: 18px 20px; max-height: 50vh;
  overflow-y: auto; white-space: pre-wrap; font-size: 15px; line-height: 1.6; background: #fcfcfd;
}
.versions { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 16px; }
.version { display: flex; align-items: center; gap: 10px; font-size: 14px; padding: 6px 0; }
.version .spacer { flex: 1; }
@media (max-width: 560px) { .who { display: none; } .hide-s { display: none; } }
.sep { height: 1px; background: var(--line); margin: 22px 0; }

/* ── Tableaux ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-2); padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 13px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:first-child td { border-top: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 650; border-top: 1px solid var(--line-2); }
tr.detail td { background: #fafafc; padding: 4px 16px 14px 32px; }
tr.detail table { font-size: 13px; }
tr.detail td td { border-top: 1px solid var(--line); padding: 8px 10px; background: transparent; }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.kpi b { display: block; font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 13px; color: var(--text-2); }
@media (max-width: 560px) { .kpis { grid-template-columns: 1fr 1fr; } .kpi b { font-size: 21px; } }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar select, .toolbar input { width: auto; font-size: 14px; padding: 8px 34px 8px 12px; border-radius: 10px; }
.toolbar input { padding-right: 12px; }

/* ── Écran de connexion ───────────────────────────────────── */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 400px; padding: 40px 32px 34px; text-align: center; }
.auth .logo { width: 56px; height: 56px; border-radius: 14px; margin-bottom: 18px; }
.auth h1 { font-size: 28px; margin-bottom: 8px; }
.auth p.muted { margin-bottom: 26px; }
.auth form { text-align: left; }
.auth .fine { font-size: 12px; color: var(--text-3); margin-top: 22px; line-height: 1.5; }
.sent-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--accent-soft); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 18px; }

/* ── Toast ─────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 90;
  background: rgba(29,29,31,.92); color: #fff; padding: 11px 20px; border-radius: 980px; font-size: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.2); animation: up .2s ease; max-width: calc(100vw - 32px);
}
.toast.err { background: var(--red); }

.loading { padding: 40px; text-align: center; color: var(--text-3); }
