:root {
  --ink: #f4f6fb;
  --green: #008751;
  --red: #ff5a63;
  --bg: #131b2e;
  --line: rgba(255, 255, 255, 0.08);
  --muted: #9aa3b5;
  --card: #1c2438;
  --shadow: 0 18px 40px -28px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }

html { overflow-x: clip; }

body {
  margin: 0;
  max-width: 100%;
  overflow-x: clip;
  font-family: Outfit, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

h1, h2, .brand strong, .card .value {
  font-family: Sora, Outfit, sans-serif;
}

a { color: inherit; }

label { display: flex; flex-direction: column; gap: 6px; }
[hidden] { display: none !important; }
.stack label input,
.stack label select,
.stack label textarea,
.login input { width: 100%; }
label.inline { flex-direction: row; align-items: center; }
label.inline input { width: auto; }

.shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
  min-width: 0;
}

.side {
  background: #0d1322;
  color: white;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px;
}

.brand strong {
  font-size: 18px;
  letter-spacing: 0.08em;
}

.brand span {
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav a {
  text-decoration: none;
  color: rgba(255, 255, 255, 0.82);
  padding: 10px 12px;
  border-radius: 10px;
}

.nav a.active,
.nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.side form { margin-top: auto; }

.main {
  min-width: 0;
  max-width: 100%;
  padding: 28px;
}

.topbar, .backdrop { display: none; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 18px;
}

h1, h2, p, td, th, a, code {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 650;
}

.muted { color: var(--muted); }

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
  max-width: 100%;
}

.card .label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card .value {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 650;
}

.stack { display: flex; flex-direction: column; gap: 14px; }
.choices { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0; padding: 0; border: 0; }
.choices legend { width: 100%; font-size: 13px; font-weight: 600; }
.choices label { width: auto; }

.choice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.choice input {
  margin-top: 4px;
}

.choice strong,
.choice .muted {
  display: block;
}

.choice .muted {
  margin-top: 2px;
  font-size: 13px;
}

.proof-shot {
  display: block;
  width: min(100%, 280px);
  margin-top: 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: top;
}

th { color: var(--muted); font-weight: 600; font-size: 12px; }

.filters, .inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

input, select, textarea {
  border: 1px solid var(--line);
  background: #0f1524;
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 0;
}

textarea { width: 100%; min-height: 80px; }

.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: #f4f6fb;
  color: #131b2e;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn.green { background: var(--green); color: white; }
.btn.red { background: var(--red); color: white; }
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.tabs, .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tabs { margin: 16px 0; }

.secret {
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: 0.08em;
  font-size: 18px;
  padding: 12px;
  border-radius: 12px;
  background: #0f1524;
  border: 1px solid var(--line);
}

.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  background: #eef2f6;
}

.badge.reussi, .badge.confirme, .badge.associe { background: #e5f6ee; color: #067647; }
.badge.sms-state.envoye { background: var(--green); color: #fff; }
.badge.sms-state.echec { background: var(--red); color: #fff; }
.badge.echec, .badge.rejete, .badge.expire, .badge.annule { background: #fde8ea; color: #b42318; }
.badge.en_attente_paiement, .badge.en_cours, .badge.en_attente_partenaire, .badge.en_file, .badge.envoye_appareil, .badge.recu { background: #fff6e5; color: #b54708; }
.badge.litige, .badge.non_associe { background: #f4e8ff; color: #6941c6; }

.alert {
  border-radius: 14px;
  padding: 12px 14px;
  background: #e5f6ee;
  color: #067647;
}

.alert.error { background: #fde8ea; color: #b42318; }
.alert.warn { background: #fff6e5; color: #b54708; }

.token {
  font-family: Consolas, monospace;
  word-break: break-all;
  background: #0f1524;
  color: #f4f6fb;
  border-radius: 12px;
  padding: 12px;
}

.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: safe center;
  justify-content: center;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  overflow: auto;
  background:
    radial-gradient(circle at top left, rgba(0, 135, 81, 0.18), transparent 32%),
    var(--bg);
}

.login {
  width: min(420px, 100%);
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.meta { font-size: 13px; color: var(--muted); }

.choice {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.split {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 14px;
}

@media (max-width: 980px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .grid, .split { grid-template-columns: 1fr; }
  .main {
    padding: calc(92px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
  }
  h1 { font-size: 22px; }
  .card .value { font-size: 20px; }
  .top { align-items: stretch; flex-direction: column; }
  .filters, .inline, form.card.inline {
    flex-direction: column;
    align-items: stretch;
  }
  .filters > *,
  .inline > *,
  .filters input,
  .filters select,
  .filters .btn,
  .inline input,
  .inline .btn,
  form.card.inline input,
  form.card.inline .btn {
    width: 100%;
    max-width: 100%;
  }
  .topbar {
    display: flex;
    position: fixed;
    z-index: 30;
    top: 0;
    left: 0;
    right: 0;
    align-items: center;
    gap: 12px;
    min-height: 60px;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
    background: #0d1322;
    border-bottom: 1px solid var(--line);
    color: white;
  }
  .topbar strong { letter-spacing: 0.08em; }
  .menu-btn {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: white;
    display: grid;
    place-items: center;
    cursor: pointer;
  }
  .menu-icon,
  .menu-icon::before,
  .menu-icon::after {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: white;
    position: relative;
  }
  .menu-icon::before,
  .menu-icon::after {
    content: "";
    position: absolute;
    left: 0;
  }
  .menu-icon::before { top: -6px; }
  .menu-icon::after { top: 6px; }
  .backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
  }
  body.menu-open { overflow: hidden; }
  body.menu-open .backdrop { opacity: 1; pointer-events: auto; }
  .side {
    position: fixed;
    z-index: 40;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(84vw, 300px);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    overflow: auto;
    padding-top: calc(22px + env(safe-area-inset-top));
    padding-bottom: calc(22px + env(safe-area-inset-bottom));
  }
  body.menu-open .side { transform: none; }
  table, thead, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tr {
    padding: 8px 0 12px;
    border-bottom: 1px solid var(--line);
  }
  td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    border: 0;
    padding: 6px 0;
    text-align: right;
  }
  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    text-align: left;
    flex: 0 0 34%;
  }
  td:not([data-label]) { justify-content: flex-start; text-align: left; }
  td:not([data-label])::before { content: none; }
  td.wide {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }
  td .btn { width: auto; }
}
