:root {
  --bg: #f4f5f9;
  --card: #ffffff;
  --text: #1c1f2a;
  --muted: #6b7083;
  --border: #e3e5ec;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --error: #c62828;
  --success: #1b8a4b;
  --warning: #a35d00;
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Page de connexion ---------- */
body.centered { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; }

/* ---------- Barre du haut ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 10px; }
.brand .role { font-size: 0.75rem; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; }
.topbar .who { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 0.9rem; }

.mock-banner {
  background: #fff4e0; color: var(--warning); text-align: center; padding: 6px; font-size: 0.85rem; font-weight: 500;
}

.container { max-width: 1100px; margin: 0 auto; padding: 24px; }

/* ---------- Onglets admin ---------- */
.tabs-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; overflow-x: auto; overflow-y: hidden; }
.tabs-bar button {
  border: 0; background: none; padding: 12px 16px; font: inherit; font-weight: 500; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs-bar button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Cartes ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(20, 24, 40, 0.06);
  border: 1px solid var(--border);
  padding: 24px;
}
.card + .card { margin-top: 20px; }
h1 { margin: 0 0 4px; font-size: 1.4rem; }
h2 { margin: 0 0 16px; font-size: 1.1rem; }
.subtitle { margin: 0 0 20px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 380px 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Statistiques ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat .label { color: var(--muted); font-size: 0.85rem; }
.stat .value { font-size: 1.4rem; font-weight: 700; margin-top: 2px; }
.stat.success .value { color: var(--success); }

/* ---------- Formulaires ---------- */
label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 0.9rem; }
.field { margin-bottom: 16px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type="email"], input[type="text"], input[type="password"], input[type="search"], select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.amount-wrap { position: relative; }
.amount-wrap input { padding-right: 32px; }
.amount-wrap span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.hint { font-size: 0.82rem; color: var(--muted); margin-top: 4px; }

.btn {
  display: inline-flex; justify-content: center; align-items: center; gap: 8px;
  border: 0; border-radius: 8px; padding: 11px 16px; font: inherit; font-weight: 600;
  background: var(--accent); color: #fff; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.light { background: var(--accent-soft); color: var(--accent); }
.btn.light:hover { background: #e2e5ff; }
.btn.danger { background: #fdecea; color: var(--error); }
.btn.sm { padding: 6px 10px; font-size: 0.85rem; font-weight: 500; }

.link-btn { border: 0; background: none; padding: 0; font: inherit; color: var(--accent); cursor: pointer; font-size: 0.9rem; }
.link-btn:hover { text-decoration: underline; }

.spinner {
  width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.alert { padding: 10px 12px; border-radius: 8px; background: #fdecea; color: var(--error); margin-bottom: 16px; font-size: 0.9rem; }
.alert.ok { background: #e3f6ea; color: var(--success); }
.alert.warn { background: #fff4e0; color: var(--warning); }

/* ---------- Résultat d'un lien créé ---------- */
.result { border: 1px solid #c7e8d3; background: #f3fbf6; border-radius: 10px; padding: 16px; margin-top: 16px; }
.result strong { display: block; margin-bottom: 8px; }
.copy-box { display: flex; gap: 8px; }
.copy-box input { flex: 1; min-width: 0; font-size: 0.85rem; background: #fff; }

/* ---------- Tableaux ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.toolbar input[type="search"] { flex: 1; min-width: 180px; }
.toolbar select { width: auto; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td .sub { display: block; color: var(--muted); font-size: 0.82rem; }
td .note { display: block; font-size: 0.82rem; margin-top: 4px; color: var(--warning); }
td .note.failed { color: var(--error); }
td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.actions { white-space: nowrap; text-align: right; }
td.actions .link-btn + .link-btn { margin-left: 12px; }
.empty { text-align: center; color: var(--muted); padding: 32px 0; }

.badge { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge.open { background: #fff4e0; color: var(--warning); }
.badge.paid, .badge.sent, .badge.on { background: #e3f6ea; color: var(--success); }
.badge.failed { background: #fdecea; color: var(--error); }
.badge.logged { background: var(--accent-soft); color: var(--accent); }

/* ---------- Fenêtre (modale) ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 24, 40, 0.45); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: #fff; border-radius: var(--radius); padding: 24px; width: 100%; max-width: 440px; }
.modal h2 { margin-bottom: 8px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 1.05rem; background: var(--bg); padding: 10px 12px; border-radius: 8px; word-break: break-all; }

/* ---------- Petite notification ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 0.9rem; z-index: 60;
}

/* ---------- Réglages ---------- */
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: 0; }
.checklist .icon { font-size: 1.1rem; }
.checklist small { display: block; color: var(--muted); }
code { background: var(--bg); padding: 1px 6px; border-radius: 4px; font-size: 0.88em; word-break: break-all; }
