:root {
  --bg: #0b1220;
  --card: #111a2e;
  --line: #1e2b46;
  --text: #e6edf7;
  --muted: #8ea0bf;
  --accent: #3b82f6;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.45rem; margin: 0 0 .6rem; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .3rem; }
p { margin: .3rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Barre du haut */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 16px;
  background: rgba(11, 18, 32, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .3px; color: var(--text); }
.brand-logo { height: 32px; width: auto; border-radius: 8px; background: #fff; padding: 2px; display: block; }
.hero-logo { height: 150px; width: auto; border-radius: 18px; background: #fff; padding: 12px; margin-bottom: 12px; display: block; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Espace client façon application --- */
.welcome {
  background: linear-gradient(135deg, #12306b, #1d4ed8);
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 20px; padding: 15px 18px; margin-bottom: 14px; color: #fff;
}
.welcome .pill {
  display: inline-block; font-size: .7rem; letter-spacing: .09em; text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, .38); border-radius: 999px; padding: 3px 10px;
}
.welcome .hello { font-size: 1.3rem; font-weight: 700; margin: 10px 0 12px; }
.welcome a { color: #dbeafe; text-decoration: underline; }

.id-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.id-label { font-size: .82rem; color: rgba(255, 255, 255, .78); }
.id-value { font-weight: 600; word-break: break-all; }
.copy-btn {
  background: rgba(255, 255, 255, .17); border: 0; color: #fff; border-radius: 10px;
  padding: 6px 11px; cursor: pointer; font-size: 1rem; line-height: 1;
}
.copy-btn:active { transform: scale(.95); }
.copy-btn.done { background: rgba(34, 197, 94, .9); }

.big-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.big-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 20px 12px; border-radius: 20px; text-decoration: none;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
.big-btn .ico { font-size: 1.7rem; line-height: 1; font-weight: 700; }
.big-btn .lab { font-weight: 700; }
.big-btn .sub { font-size: .78rem; color: var(--muted); text-align: center; }
.big-btn.depot { background: rgba(34, 197, 94, .12); border-color: rgba(34, 197, 94, .35); }
.big-btn.depot .ico, .big-btn.depot .lab { color: #4ade80; }
.big-btn.retrait { background: rgba(59, 130, 246, .12); border-color: rgba(59, 130, 246, .35); }
.big-btn.retrait .ico, .big-btn.retrait .lab { color: #93c5fd; }

.pills-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: .9rem;
}

/* Barre de navigation du bas (téléphone) */
/* Badge de notifications et avatar */
.bell { position: relative; display: inline-flex; align-items: center; text-decoration: none; }
.bell-ico { font-size: 1.05rem; }
.badge-count {
  position: absolute; top: -6px; right: -8px; min-width: 17px; height: 17px;
  border-radius: 999px; background: var(--red); color: #fff; font-size: .68rem;
  line-height: 17px; text-align: center; padding: 0 4px; font-weight: 700;
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; text-decoration: none;
}
.avatar-big { width: 54px; height: 54px; font-size: 1.5rem; flex: 0 0 auto; }
.profile-head { display: flex; align-items: center; gap: 14px; }

.notif-list { list-style: none; padding: 0; margin: 0; }
.notif {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 4px; border-bottom: 1px solid var(--line); font-size: .93rem;
}
.notif.unread { font-weight: 600; }
.notif.unread::before { content: "•"; color: var(--accent); margin-right: 6px; }

.app-nav { display: none; }
@media (max-width: 720px) {
  .app-nav {
    display: flex; align-items: center; justify-content: space-around;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    background: rgba(17, 26, 46, .97); border-top: 1px solid var(--line);
    backdrop-filter: blur(10px);
  }
  .app-nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: .72rem; color: var(--muted); min-width: 72px; padding: 4px 0;
  }
  .app-nav-item .n-ico { font-size: 1.25rem; line-height: 1; }
  .app-nav-item.active { color: var(--text); }
  .app-nav-item.active .n-ico { color: var(--accent); }
  .app-nav-chat {
    width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
    margin-top: -22px; box-shadow: 0 8px 20px rgba(59, 130, 246, .45);
  }
  body { padding-bottom: 80px; }
  /* les liens déjà présents dans la barre du bas ne sont pas répétés en haut */
  .topbar nav a[href="/dashboard"], .topbar nav a[href="/chat"] { display: none; }
}
.topbar nav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar nav a { color: var(--text); font-size: .92rem; }
.topbar nav a:hover { color: var(--accent); }
.inline { display: inline; }
.linkbtn {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font: inherit; font-size: .92rem; padding: 0;
}
.linkbtn:hover { color: var(--red); }

/* Contenu */
.wrap { max-width: 780px; margin: 0 auto; padding: 16px 14px 40px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}
.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.grid3 .card { margin-bottom: 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* Boutons */
.btn {
  display: inline-block; background: var(--accent); color: #fff;
  border: 0; border-radius: 10px; padding: 10px 16px;
  font: inherit; font-weight: 600; cursor: pointer; text-align: center;
}
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.small { padding: 6px 12px; font-size: .88rem; }
.cta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.quick { display: flex; gap: 10px; margin-top: 8px; }
.quick .btn { flex: 1; }

/* Héros */
.hero h1 { font-size: 1.9rem; margin-bottom: .2rem; }
.tagline { color: var(--muted); margin-bottom: .6rem; }
.steps { margin: .4rem 0 0; padding-left: 1.2rem; }
.steps li { margin: .35rem 0; }

/* Formulaires */
.form label { display: block; margin: .65rem 0; font-size: .92rem; color: var(--muted); }
.form input, .form select, .status-form input, .status-form select {
  width: 100%; margin-top: .3rem;
  background: #0c1526; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font: inherit;
}
.form button { width: 100%; margin-top: .8rem; }

/* Tableaux */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 600; font-size: .82rem; }
.kv { width: 100%; border-collapse: collapse; margin: .4rem 0; }
.kv td { padding: 6px 4px; border-bottom: 1px solid var(--line); font-size: .93rem; }
.kv td:first-child { color: var(--muted); width: 40%; }

/* Badges de statut */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: .76rem; font-weight: 700; border: 1px solid;
  white-space: nowrap;
}
.badge.en_attente { color: var(--amber); border-color: rgba(245, 158, 11, .45); background: rgba(245, 158, 11, .1); }
.badge.en_cours { color: var(--accent); border-color: rgba(59, 130, 246, .45); background: rgba(59, 130, 246, .1); }
.badge.paye { color: var(--green); border-color: rgba(34, 197, 94, .45); background: rgba(34, 197, 94, .1); }
.badge.refuse { color: var(--red); border-color: rgba(239, 68, 68, .45); background: rgba(239, 68, 68, .1); }

/* Stats */
.stat .label { display: block; color: var(--muted); font-size: .8rem; }
.stat .value { font-size: 1.15rem; font-weight: 700; }

/* Messages flash */
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-size: .93rem; border: 1px solid; }
.flash.ok { color: var(--green); border-color: rgba(34, 197, 94, .5); background: rgba(34, 197, 94, .08); }
.flash.error { color: var(--red); border-color: rgba(239, 68, 68, .5); background: rgba(239, 68, 68, .08); }

/* Notes */
.note { background: rgba(59, 130, 246, .08); border: 1px solid rgba(59, 130, 246, .35); border-radius: 10px; padding: 10px 12px; margin: .7rem 0; font-size: .92rem; }

/* Timeline */
.timeline { list-style: none; margin: .5rem 0; padding: 0; }
.timeline li { padding: .45rem 0 .45rem 0; border-bottom: 1px dashed var(--line); color: var(--muted); }
.timeline li.done { color: var(--green); }
.timeline li.current { color: var(--amber); font-weight: 600; }
.timeline li.fail { color: var(--red); }

/* Admin */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.tabs a { padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .86rem; }
.tabs a.active { color: #fff; background: var(--accent); border-color: var(--accent); }
.orders .order-item { border: 1px solid var(--line); border-radius: 10px; margin: .5rem 0; overflow: hidden; }
.order-item summary {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 10px 12px; cursor: pointer; background: #0c1526;
}
.order-item summary .oid { font-weight: 700; }
.order-detail { padding: 10px 12px; border-top: 1px solid var(--line); }
.status-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.status-form select { width: auto; }
.status-form input { flex: 1; min-width: 160px; width: auto; }
.status-form .btn { width: auto; }

/* Chat */
.chat-card .chat-box { display: flex; flex-direction: column; }
.chat-messages {
  height: 52vh; min-height: 260px; overflow-y: auto;
  background: #0c1526; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; display: flex; flex-direction: column; gap: 8px;
}
.msg {
  max-width: 82%; padding: 8px 12px; border-radius: 14px;
  font-size: .93rem; word-wrap: break-word; white-space: pre-wrap;
}
.msg.them { align-self: flex-start; background: #182441; border: 1px solid var(--line); }
.msg.me { align-self: flex-end; background: rgba(59, 130, 246, .25); border: 1px solid rgba(59, 130, 246, .5); }
.msg .t { display: block; font-size: .68rem; color: var(--muted); margin-top: 3px; }
.chat-form { display: flex; gap: 8px; margin-top: 10px; }
.chat-form input {
  flex: 1; background: #0c1526; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit;
}

/* Code USSD (instructions de paiement) */
.ussd {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 1.05rem; font-weight: 700; letter-spacing: .3px;
  background: #0c1526; border: 1px dashed var(--accent);
  border-radius: 10px; padding: 10px 12px; margin: 6px 0;
  word-break: break-all;
}

/* Pied de page */
.foot { text-align: center; padding: 18px 14px 30px; color: var(--muted); font-size: .85rem; }
.foot p { margin: 2px 0; }

/* Choix de l'opérateur : cartes cliquables avec logo */
.field-label { margin: 12px 0 6px; font-size: .9rem; color: var(--muted, #9aa7b8); font-weight: 600; }
.op-pick { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.op-card {
  position: relative;
  flex: 1 1 130px; display: flex; align-items: center; gap: 10px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px;
}
.op-card input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.op-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59, 130, 246, .3); }
.op-card:focus-within { border-color: var(--accent); }
.op-logo { width: 40px; height: 40px; border-radius: 9px; background: #fff; padding: 2px; object-fit: contain; }
.op-name { font-weight: 600; }

/* Cadre du code USSD : vert, avec le code en gras */
#ussd-hint {
  background: rgba(34, 197, 94, .1);
  border-color: rgba(34, 197, 94, .45);
}
.ussd-code {
  font-weight: 800; letter-spacing: .02em; color: #4ade80;
  background: rgba(34, 197, 94, .14); padding: 2px 7px; border-radius: 6px;
  white-space: nowrap;
}
