:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #5f6b7a;
  --line: #e3e8ef;
  --primary: #1a73e8;
  --primary-h: #1666cf;
  --primary-soft: #e8f0fe;
  --ok: #188038; --ok-soft: #e6f4ea;
  --warn: #b06000; --warn-soft: #fef7e0;
  --err: #c5221f; --err-soft: #fce8e6;
  --info: #1967d2; --info-soft: #e8f0fe;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; margin: 0 0 4px; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0; font-weight: 600; }
h3 { font-size: 16px; margin: 0; font-weight: 600; }
code { background: #f1f3f4; padding: 2px 6px; border-radius: 6px; font-size: 13px; word-break: break-all; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 13px; }
.text-warn { color: var(--warn); font-weight: 600; }
.text-error { color: var(--err); margin: 6px 0 0; }

/* Barre du haut */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 60px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand.big { font-size: 22px; justify-content: center; margin-bottom: 6px; }
.logo { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; color: #fff; font-weight: 700;
  background: linear-gradient(135deg, #1a73e8, #6b4fe0); }
.topbar nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topbar nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap; font-weight: 500; }
.topbar nav a:hover { background: #f1f3f4; text-decoration: none; color: var(--text); }
.topbar nav a.active { background: var(--primary-soft); color: var(--primary); }
.user { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; white-space: nowrap; }

.container { max-width: 1120px; margin: 0 auto; padding: 28px 24px 80px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 24px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 500; cursor: pointer; transition: background .15s, box-shadow .15s, border-color .15s; text-decoration: none !important; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); box-shadow: var(--shadow); }
.btn-primary:disabled { background: #a8c7fa; cursor: not-allowed; }
.btn-ghost { background: #fff; color: var(--primary); border-color: var(--line); }
.btn-ghost:hover { background: #f8fafd; border-color: #c6d4e8; }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-icon { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 6px 8px; border-radius: 6px; }
.btn-icon:hover { background: var(--err-soft); color: var(--err); }
.btn.copied { background: var(--ok); color: #fff; border-color: var(--ok); }

/* Formulaires */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: #3c4043; }
input, select, textarea { font: inherit; font-size: 14px; color: var(--text); padding: 9px 11px; border: 1px solid #cfd6df; border-radius: 8px; background: #fff; width: 100%;
  transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,115,232,.15); }
textarea { resize: vertical; line-height: 1.5; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; white-space: nowrap; }
.grid2, .grid3, .grid4 { display: grid; gap: 14px; }
.grid2 { grid-template-columns: repeat(2, 1fr); }
.grid3 { grid-template-columns: repeat(3, 1fr); }
.grid4 { grid-template-columns: repeat(4, 1fr); align-items: end; }
.span2 { grid-column: span 2; } .span3 { grid-column: span 3; }
.narrow { max-width: 260px; }
.char-count { align-self: flex-end; font-size: 12px; color: var(--muted); font-weight: 400; margin-top: -2px; }
.char-count.over { color: var(--err); font-weight: 600; }
@media (max-width: 800px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } .span2, .span3 { grid-column: auto; } .user span { display: none; } }

/* Cartes pliables */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; cursor: pointer; user-select: none; border-radius: var(--radius); }
.card-head:hover { background: #fafbfd; }
.card-head:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.card-tools { display: flex; align-items: center; gap: 10px; }
.chevron { width: 10px; height: 10px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .25s; margin: 0 4px 4px; }
.card.collapsed .chevron { transform: rotate(-45deg); margin-bottom: 0; }
.card-body { padding: 4px 20px 20px; display: flex; flex-direction: column; gap: 14px; overflow: hidden;
  transition: max-height .3s ease, opacity .2s ease, padding .3s ease; }
.card.collapsed .card-body { max-height: 0 !important; opacity: 0; padding-top: 0; padding-bottom: 0; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: #f1f3f4; color: var(--muted); }

/* Alertes */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-ok { background: var(--ok-soft); color: #0d652d; border-color: #ceead6; }
.alert-info { background: var(--info-soft); color: #174ea6; border-color: #d2e3fc; }
.alert-warn { background: var(--warn-soft); color: #7a4100; border-color: #feefc3; }
.alert-error { background: var(--err-soft); color: #a50e0e; border-color: #fad2cf; }

/* Tableau de bord */
.platform-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-bottom: 20px; }
.pcard { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px;
  border-top: 4px solid var(--pc); }
.pcard-top { display: flex; align-items: center; gap: 8px; }
.pcard-top h3 { flex: 1; }
.pcard-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 8px; flex-wrap: wrap; }
.pdot { width: 10px; height: 10px; border-radius: 50%; background: var(--pc); display: inline-block; flex: none; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }

/* Onglets plateformes */
.tabs { display: flex; gap: 6px; margin-bottom: 20px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { display: flex; align-items: center; gap: 8px; padding: 10px 16px; color: var(--muted); font-weight: 500; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--text); border-bottom-color: var(--pc); }
.tab .count { background: var(--warn-soft); color: var(--warn); border-radius: 999px; padding: 0 7px; font-size: 12px; font-weight: 700; }
.switch { flex-direction: row; align-items: center; gap: 8px; font-size: 14px; }

/* Champs générés */
.field { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fff; }
.field.is-changed { border-left: 4px solid var(--warn); }
.field.is-same { border-left: 4px solid #ceead6; }
.field-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.spacer { flex: 1; }
.counter { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.counter.over { color: var(--err); font-weight: 700; }
pre.value { margin: 0; white-space: pre-wrap; word-break: break-word; font: inherit; font-size: 14px; background: #f8fafd; border-radius: 8px; padding: 10px 12px; max-height: 260px; overflow: auto; }
.override { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
body.only-changed .field.is-same { display: none; }
.empty { text-align: center; padding: 48px; color: var(--muted); background: #fff; border: 1px dashed var(--line); border-radius: var(--radius); }

/* Lignes répétables */
.rows { display: flex; flex-direction: column; gap: 8px; }
.row-item { background: #fafbfd; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.row-item.inline { display: flex; gap: 8px; align-items: center; }
.row-item.inline .grow { flex: 1; min-width: 0; }
.row-item.inline select { width: auto; }
.row-item .xs { width: 90px; }
.row-item.block { display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.row-head { display: flex; align-items: center; gap: 8px; }
.row-head strong { flex: 1; }
.row-item.dragging { opacity: .5; }
.drag { cursor: grab; color: #9aa4b1; letter-spacing: -3px; padding: 0 4px; user-select: none; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.savebar { position: sticky; bottom: 0; display: flex; gap: 12px; padding: 14px 16px; background: rgba(255,255,255,.95); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 -4px 16px rgba(16,24,40,.06); }
.savebar input { flex: 1; }
@media (max-width: 800px) { .row-item.inline { flex-wrap: wrap; } }

/* Divers */
.info-box { background: #f8fafd; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.info-box p { margin: 0 0 8px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 8px 0; align-items: center; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; }
[data-copytext] { cursor: pointer; }
[data-copytext]:hover { background: var(--primary-soft); }
fieldset.pf { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
fieldset.pf legend { display: flex; align-items: center; gap: 8px; font-weight: 600; padding: 0 6px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding: 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table td form { margin: 0; }
.add-user { padding-top: 12px; border-top: 1px solid var(--line); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 16px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.tl-date { width: 130px; flex: none; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.tl-body { flex: 1; }
.timeline form { margin: 0; }
.inline-form { margin: 0; }

/* Pages d'authentification */
.center-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-box { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 32px; box-shadow: 0 8px 30px rgba(16,24,40,.08); text-align: center; }
.auth-box.wide { max-width: 760px; text-align: left; }
.auth-box.wide .brand { justify-content: flex-start; }
.auth-box form { text-align: left; margin-top: 16px; }
.auth-box > .muted { margin-bottom: 20px; }
.sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 18px 0 0; }
.sep::before, .sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.checklist .ok { color: var(--ok); } .checklist .ko { color: var(--err); font-weight: 600; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: #202124; color: #fff; padding: 10px 18px; border-radius: 8px;
  opacity: 0; transition: all .25s; z-index: 100; font-size: 14px; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.override[hidden], [hidden] { display: none !important; }
body.only-changed .card.no-change { display: none; }
