/* --- Layout --- */
/* Conçu mobile-first (voir cahier des charges) ; sur un écran large (usage web
   bureau), on centre la colonne plutôt que d'étirer les cartes sur toute la
   largeur — cohérent avec .auth-card (max-width déjà présent depuis le
   Sprint 1). Le fond crème continue de remplir l'écran de part et d'autre. */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: 76px;
  position: relative;
}

.app-content {
  flex: 1;
}

.section {
  padding: 20px 16px 0;
}

.section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}

.page-header {
  background: var(--color-header-bg);
  color: var(--color-header-text);
  padding: 20px 16px 24px;
  border-radius: 0 0 24px 24px;
}

.page-header h1 {
  font-size: 20px;
  font-weight: 700;
}

.loading,
.empty-state {
  padding: 24px 16px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 14px;
}

/* --- Bottom nav --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  background: var(--color-card-bg);
  border-top: 1px solid var(--color-border);
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
}

.nav-item {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--color-text-muted);
  padding: 6px 0;
}

.nav-item svg {
  width: 22px;
  height: 22px;
}

.nav-item.is-active {
  color: var(--color-header-bg);
  font-weight: 700;
}

/* --- Accueil header --- */
.home-header {
  background: var(--color-header-bg);
  color: var(--color-header-text);
  padding: 20px 16px 22px;
  border-radius: 0 0 28px 28px;
}

.home-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.home-brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Logo Spark Manager sans fond : l'icône seule (les trois personnages, PNG transparent). Le logo complet
   contient du texte noir, illisible sur le vert foncé des en-têtes : on n'y affiche que l'icône. */
.home-logo {
  width: 28px;
  height: 42px;
  flex: none;
  background: url("/assets/icons/logo-mark.png") no-repeat center / contain;
}

.home-brand {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  opacity: 0.75;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.home-greeting {
  margin-top: 6px;
  font-size: 18px;
  font-weight: 600;
}

.balance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.balance-card {
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.balance-label {
  font-size: 11px;
  letter-spacing: 0.04em;
  opacity: 0.65;
}

.balance-value {
  font-size: 22px;
  font-weight: 700;
}

.balance-add-btn {
  margin-top: 4px;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.balance-add-btn:active {
  background: rgba(255, 255, 255, 0.12);
}

.rate-pill {
  margin-top: 12px;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
}

.rate-pill strong {
  font-size: 15px;
}

/* Achat et vente empilés : la ligne unique débordait sur "Modifier" en mobile. */
.rate-pair {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-left: auto;
  margin-right: 14px;
  text-align: right;
  white-space: nowrap;
}

.rate-edit {
  text-decoration: underline;
  font-size: 13px;
  white-space: nowrap;
}

/* --- Action cards --- */
.action-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.action-card {
  background: var(--color-card-bg);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-card);
}

.action-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.action-text strong {
  font-size: 15px;
  color: var(--color-primary-dark);
}

.action-text span {
  font-size: 12px;
  color: var(--color-text-muted);
}

.badge-soon {
  font-size: 11px;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border-radius: 999px;
  padding: 4px 10px;
}

.action-card-link {
  width: 100%;
  border: none;
  text-align: left;
  font: inherit;
  color: inherit;
}

.chevron {
  width: 18px;
  height: 18px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.op-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-primary-dark);
  white-space: nowrap;
}

/* --- Sub-page (Faire un change, Vente d'unités) --- */
.app-shell-sub {
  padding-bottom: 24px;
}

.sub-page-header {
  background: var(--color-header-bg);
  color: var(--color-header-text);
  padding: 18px 16px 22px;
  border-radius: 0 0 24px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.sub-page-header h1 {
  font-size: 18px;
  font-weight: 700;
}

.back-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-header-text);
  flex-shrink: 0;
}

.back-btn svg {
  width: 20px;
  height: 20px;
}

/* --- Info cards / forms --- */
.info-card {
  background: var(--color-card-bg);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 14px;
}

.field input {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 16px;
  color: var(--color-text);
  background: var(--color-card-bg);
}

.field-inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.field-inline input {
  width: 80px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--color-text);
  margin-top: 6px;
}

fieldset.field {
  border: none;
  padding: 0;
}

.inline-form {
  background: var(--color-card-bg);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-card);
}

.operator-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-card-bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-card);
}

.operator-name {
  font-weight: 600;
  font-size: 14px;
}

#operators-form .btn,
#rate-form .btn {
  margin-top: 4px;
}

/* --- Vente d'unités : choix opérateur / montants prédéfinis --- */
.operator-choice,
.preset-amounts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.operator-choice-btn,
.preset-amount-btn {
  border: 1px solid var(--color-border);
  background: var(--color-card-bg);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.operator-choice-btn.active,
.preset-amount-btn.active {
  background: var(--color-header-bg);
  border-color: var(--color-header-bg);
  color: #fff;
}

/* --- Indicateur de connexion / synchronisation (Sprint 6) --- */
.sync-indicator {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  /* Reste collé au coin de la colonne centrée (480px) plutôt qu'au bord réel
     du viewport sur un écran large — identique à 10px sur mobile puisque
     (100vw - 480px) y est négatif. */
  right: max(10px, calc((100vw - 480px) / 2 + 10px));
  z-index: 50;
}

.sync-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(2px);
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sync-dot-green { background: #2e9e5b; }
.sync-dot-orange { background: #e08a2b; }
.sync-dot-blue { background: #3b82c4; }
.sync-dot-red { background: #c0392b; }

.sync-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(280px, 78vw);
  background: var(--color-card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 12px;
}

.sync-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
}

.sync-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--color-border);
  font-size: 12px;
}

.sync-item:first-child {
  border-top: none;
}

/* --- Buttons --- */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 700;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--color-header-bg);
  color: #fff;
}

.btn-primary:disabled {
  opacity: 0.6;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-danger);
}

.btn-link {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 13px;
  text-decoration: underline;
  margin-top: 16px;
  width: 100%;
}

.form-error {
  color: var(--color-danger);
  font-size: 13px;
  margin-bottom: 10px;
}

.form-success {
  color: var(--color-primary-dark);
  font-size: 13px;
  margin-bottom: 10px;
}

/* --- Auth screens --- */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--color-bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-card-bg);
  border-radius: var(--radius-lg);
  padding: 28px 22px;
  box-shadow: var(--shadow-card);
}

/* Logo complet recadré (PNG transparent, sans marge) : sur fond clair le texte noir reste lisible. */
.auth-logo {
  display: block;
  width: 104px;
  height: auto;
  margin: 0 auto 10px;
}

.auth-logo-small {
  width: 68px;
  margin-bottom: 6px;
}

.auth-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--color-header-bg);
}

.auth-card-centered .auth-title,
.auth-card-centered .auth-subtitle {
  text-align: center;
}

.auth-subtitle {
  margin-top: 6px;
  color: var(--color-text-muted);
  font-size: 14px;
  margin-bottom: 20px;
}

.auth-tabs {
  display: flex;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  border: none;
  background: none;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.auth-tab.is-active {
  background: var(--color-card-bg);
  color: var(--color-text);
  box-shadow: var(--shadow-card);
}

.auth-form .btn {
  margin-top: 6px;
}

/* --- Impression du reçu --- */
@media print {
  .no-print,
  .sub-page-header,
  .connection-indicator {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .app-shell {
    max-width: none !important;
    box-shadow: none !important;
  }

  .app-content,
  .app-content .section {
    padding: 0 !important;
  }

  .receipt-card {
    box-shadow: none !important;
    border-radius: 0 !important;
    background: #fff !important;
  }
}

/* Aperçu du reçu selon le format choisi (la page d'impression reprend la même largeur). */
.receipt-card.receipt-80 {
  max-width: 76mm;
  margin-left: auto;
  margin-right: auto;
  font-size: 13px;
}

.receipt-card.receipt-a4 {
  max-width: 100%;
  font-size: 15px;
}

@media print {
  .receipt-card.receipt-80 {
    max-width: 74mm;
    font-size: 11px;
  }

  .receipt-card.receipt-a4 {
    font-size: 14px;
  }
}

/* --- Administration (super admin) --- */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.admin-stats .info-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 6px;
}

.admin-stats strong {
  font-size: 22px;
}

.admin-filters {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.admin-filter {
  flex: 1;
  border: 1px solid var(--color-border);
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 8px;
  font-size: 13px;
}

.admin-filter.is-active {
  background: var(--color-header-bg);
  color: #fff;
}

.admin-tenant {
  margin-bottom: 10px;
}

.admin-tenant-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.admin-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--color-primary-dark);
  color: #fff;
}

.admin-badge.is-suspended {
  background: var(--color-danger);
}

.admin-tenant.is-suspended {
  opacity: 0.85;
}

/* --- Version web (bureau de change) ---
   Téléphone : colonne de 480 px et menu en bas (inchangé).
   Tablette (>= 768 px) : colonne plus large, menu toujours en bas.
   Ordinateur (>= 1024 px) : menu en barre latérale, tableau de bord sur plusieurs colonnes. */
@media (min-width: 768px) {
  .app-shell {
    max-width: 720px;
  }

  .bottom-nav {
    max-width: 720px;
  }

  .sync-indicator {
    right: max(10px, calc((100vw - 720px) / 2 + 10px));
  }

  .balance-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
}

/* Menu latéral : tiroir qui se rabat sur téléphone et tablette ; toujours visible sur ordinateur. */
.side-menu {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(84vw, 310px);
  background: var(--color-header-bg);
  color: var(--color-header-text);
  padding: 20px 12px;
  overflow-y: auto;
  z-index: 60;
  transform: translateX(-105%);
  transition: transform 0.22s ease;
  box-shadow: none;
}

.app-shell.menu-open .side-menu {
  transform: none;
  box-shadow: 8px 0 28px rgba(0, 0, 0, 0.35);
}

.side-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 55;
}

.app-shell.menu-open .side-backdrop {
  display: block;
}

.menu-fab {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: 10px;
  z-index: 45;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: var(--color-header-bg);
  color: var(--color-header-text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.menu-fab svg {
  width: 22px;
  height: 22px;
}

/* Seule la première ligne de l'en-tête laisse la place au bouton du menu (les cartes gardent toute la largeur). */
.app-shell:has(> .menu-fab) .home-header-top {
  padding-left: 52px;
}

.app-shell:has(> .menu-fab) .page-header h1 {
  padding-left: 52px;
}

.app-shell:has(> .menu-fab) .sub-page-header {
  padding-left: 60px;
}

/* Le badge « Connecté » (fixe, en haut à droite) ne recouvre plus l'avatar. */
.home-header-top {
  padding-right: 96px;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 4px;
}

.side-brand strong {
  display: block;
  font-size: 15px;
}

.side-brand div span {
  display: block;
  font-size: 11px;
  opacity: 0.7;
}

.side-group {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  opacity: 0.55;
  margin: 18px 10px 6px;
}

.side-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: transparent;
  border: none;
  color: inherit;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  text-align: left;
  opacity: 0.85;
}

.side-item svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.side-item:hover,
.side-item.is-active {
  background: rgba(255, 255, 255, 0.12);
  opacity: 1;
}

.side-item.is-active {
  font-weight: 700;
}

.side-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}


@media (min-width: 1024px) {
  /* Espaces sans menu (écrans bloqués, abonnement expiré) : colonne centrée. */
  .app-shell {
    max-width: 820px;
    padding-bottom: 32px;
  }

  .bottom-nav {
    display: none;
  }

  .side-menu {
    width: 256px;
    z-index: 40;
    transform: none;
    transition: none;
    box-shadow: none;
  }

  .menu-fab,
  .side-backdrop {
    display: none !important;
  }

  .app-shell:has(> .menu-fab) .home-header-top,
  .app-shell:has(> .menu-fab) .page-header h1 {
    padding-left: 0;
  }

  .app-shell:has(> .menu-fab) .sub-page-header {
    padding-left: 28px;
  }

  /* Espaces avec menu : le contenu occupe toute la largeur restante. */
  .app-shell:has(> .side-menu) {
    max-width: none;
    margin: 0;
    padding-left: 256px;
  }

  .app-shell:has(> .side-menu) > .app-content {
    max-width: 1240px;
    margin: 0 auto;
    width: 100%;
  }

  /* Pages secondaires (formulaires, reçus, listes) : colonne de lecture confortable. */
  .app-shell-sub:has(> .side-menu) > .app-content,
  .app-shell-sub:has(> .side-menu) > .sub-page-header {
    max-width: 860px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
  }

  .sync-indicator {
    right: 16px;
  }

  .section {
    padding: 24px 28px 0;
  }

  .home-header,
  .page-header {
    padding-left: 28px;
    padding-right: 28px;
    border-radius: 0 0 28px 28px;
  }

  .balance-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  /* Actions rapides en grille ; les listes d'historique restent en une colonne. */
  .action-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
  }

  .app-shell-sub .action-list {
    grid-template-columns: 1fr;
  }

  .dash-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 16px;
  }
}

@media print {
  .side-menu,
  .menu-fab,
  .side-backdrop {
    display: none !important;
  }

  .app-shell:has(> .side-menu) {
    padding-left: 0 !important;
  }
}

/* --- Tableau de bord du bureau --- */
.dash-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.dash-kpi {
  background: var(--color-card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dash-kpi-label {
  font-size: 12px;
  color: var(--color-text-muted);
}

.dash-kpi-value {
  font-size: 20px;
  font-weight: 700;
}

.dash-kpi-sub {
  font-size: 12px;
  color: var(--color-text-muted);
}

.dash-panel {
  background: var(--color-card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
}

.dash-bars {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 130px;
  margin-top: 8px;
}

.dash-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  height: 100%;
  font-size: 11px;
  color: var(--color-text-muted);
}

.dash-bar i {
  display: block;
  width: 100%;
  min-height: 3px;
  background: var(--color-primary-dark);
  border-radius: 6px 6px 0 0;
}

.dash-bar.is-today i {
  background: var(--color-header-bg);
}

.dash-bar b {
  font-weight: 600;
  color: var(--color-text);
  font-size: 11px;
}

.dash-team-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--color-border);
  font-size: 14px;
}

.dash-team-row:last-child {
  border-bottom: none;
}

@media (max-width: 1023px) {
  .dash-grid > * + * {
    margin-top: 12px;
  }
}

/* --- Bilan de clôture --- */
.bilan-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--color-border);
  font-size: 14px;
}

.bilan-row:last-child {
  border-bottom: none;
}

.bilan-row strong {
  text-align: right;
}

.bilan-row-total {
  font-weight: 700;
  border-bottom-style: solid;
}

/* --- Abonnement (propriétaire) --- */
.sub-banner {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff7e6;
  color: #7a4b00;
  padding: 12px 14px;
  font-size: 14px;
  text-align: left;
}

.sub-banner.is-urgent {
  background: #fdecea;
  color: var(--color-danger);
  border-color: #f3c4bf;
}

/* --- Console du super admin (version web) --- */
.admin-console {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Barre du haut : téléphone seulement (sur ordinateur le menu est fixe à gauche). */
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--color-header-bg);
  color: var(--color-header-text);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.admin-burger {
  width: 40px;
  height: 40px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.admin-burger svg {
  width: 22px;
  height: 22px;
}

.admin-topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
}

.admin-backdrop {
  position: fixed;
  inset: 0;
  z-index: 65;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.admin-console.menu-open .admin-backdrop {
  opacity: 1;
  pointer-events: auto;
}

/* Menu : tiroir qui se rabat sur téléphone, fixe sur ordinateur (voir plus bas). */
.admin-side {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 70;
  width: min(280px, 84vw);
  background: var(--color-header-bg);
  color: var(--color-header-text);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}

.admin-console.menu-open .admin-side {
  transform: none;
  box-shadow: 8px 0 28px rgba(0, 0, 0, 0.35);
}

/* Logo + nom, puis une ligne de séparation avant le menu. */
.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 6px 16px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.admin-brand .home-logo {
  width: 34px;
  height: 50px;
}

.admin-brand-text {
  font-weight: 700;
  font-size: 18px;
  line-height: 1.15;
  display: flex;
  flex-direction: column;
}

.admin-brand-text span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.7;
}

.admin-nav,
.admin-side-foot {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-side-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.admin-nav-item {
  flex: none;
  background: transparent;
  border: none;
  color: inherit;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0.85;
  cursor: pointer;
}

.admin-nav-item svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.admin-nav-label {
  flex: 1;
}

.admin-nav-item:hover,
.admin-nav-item.is-active {
  background: rgba(255, 255, 255, 0.12);
  opacity: 1;
}

.admin-nav-item em {
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
  background: #f5a524;
  color: #1c1c1c;
  border-radius: 999px;
  padding: 1px 8px;
}

.admin-main {
  flex: 1;
  min-width: 0;
  padding: 18px 16px 48px;
}

.admin-title {
  font-size: 24px;
  margin-bottom: 16px;
}

.admin-subtitle {
  font-size: 16px;
  margin: 24px 0 10px;
}

.admin-alert {
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 14px;
}

.admin-alert.is-error {
  background: #fdecea;
  color: var(--color-danger);
}

.admin-alert.is-ok {
  background: #e8f5ee;
  color: var(--color-primary-dark);
}

.admin-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.admin-kpi {
  background: var(--color-card-bg);
  border: none;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  font: inherit;
  color: inherit;
}

button.admin-kpi {
  cursor: pointer;
}

.admin-kpi-label {
  font-size: 12px;
  color: var(--color-text-muted);
}

.admin-kpi-value {
  font-size: 24px;
}

.admin-kpi-sub {
  font-size: 12px;
  color: var(--color-text-muted);
}

.admin-badge.is-ok {
  background: var(--color-primary-dark);
}

.admin-badge.is-trial {
  background: #1d4ed8;
}

.admin-badge.is-warn {
  background: #b45309;
}

.admin-badge.is-muted {
  background: #6b7280;
}

.admin-search {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  background: #fff;
}

.admin-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.admin-chip {
  border: 1px solid var(--color-border);
  background: transparent;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
}

.admin-chip em {
  font-style: normal;
  opacity: 0.6;
  margin-left: 4px;
}

.admin-chip.is-active {
  background: var(--color-header-bg);
  color: #fff;
}

.admin-table {
  background: var(--color-card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.admin-row {
  display: block;
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
}

.admin-row-head {
  display: none;
}

.admin-cell {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  font-size: 14px;
}

.admin-cell::before {
  content: attr(data-label);
  color: var(--color-text-muted);
  font-size: 12px;
}

.admin-cell-main {
  flex-direction: column;
  gap: 2px;
}

.admin-cell-main::before {
  display: none;
}

.admin-row-wrap.is-open {
  background: rgba(0, 0, 0, 0.025);
}

.admin-detail {
  padding: 4px 14px 18px;
  border-bottom: 1px solid var(--color-border);
}

.admin-detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.admin-detail h3,
.admin-card h3 {
  font-size: 14px;
  margin-bottom: 8px;
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.admin-form input,
.admin-form select,
.admin-form textarea,
.admin-inline-input {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--color-text);
  background: #fff;
}

.admin-form .admin-check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.admin-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.admin-btn {
  border: 1px solid var(--color-border);
  background: #fff;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

.admin-btn.is-primary {
  background: var(--color-header-bg);
  border-color: var(--color-header-bg);
  color: #fff;
}

.admin-btn.is-danger {
  color: var(--color-danger);
}

.admin-card {
  background: var(--color-card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.admin-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.admin-line {
  font-size: 13px;
  margin: 2px 0;
}

@media (min-width: 1024px) {
  .admin-console {
    flex-direction: row;
  }

  .admin-topbar,
  .admin-backdrop {
    display: none;
  }

  .admin-side {
    width: 250px;
    flex: none;
    position: sticky;
    top: 0;
    z-index: auto;
    height: 100vh;
    padding: 24px 14px;
    transform: none;
    transition: none;
  }

  .admin-console.menu-open .admin-side {
    box-shadow: none;
  }

  .admin-main {
    padding: 28px 36px 64px;
    max-width: 1500px;
  }

  .admin-row {
    display: grid;
    grid-template-columns: 2.3fr 0.9fr 1.2fr 1.4fr 0.6fr 1.1fr 1fr;
    gap: 14px;
    align-items: center;
  }

  .admin-row-head {
    display: grid;
    cursor: default;
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text-muted);
    background: rgba(0, 0, 0, 0.03);
  }

  .admin-cell {
    display: block;
  }

  .admin-cell::before {
    display: none;
  }

  .admin-cell-main {
    display: flex;
  }

  .admin-row:hover:not(.admin-row-head) {
    background: rgba(0, 0, 0, 0.03);
  }

  .admin-detail-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  }
}

/* --- Graphiques de la console admin --- */
.admin-stack {
  display: flex;
  height: 16px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.06);
  margin: 10px 0;
}

.admin-stack i {
  display: block;
  height: 100%;
}

.admin-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.admin-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.admin-legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

/* Abonnement expiré : espace en lecture seule */
.readonly-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 16px 0;
  padding: 10px 14px;
  background: #fdf1ee;
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 13px;
}
.readonly-banner .btn {
  flex: none;
  padding: 6px 12px;
}
/* Période de grâce : avertissement orange (rien n'est encore bloqué), distinct du rouge de la lecture seule. */
.readonly-banner.is-grace {
  background: #fdf3e7;
  border-color: var(--color-accent);
}
/* Sur mobile le bouton ☰ flottant occupe le coin haut-gauche : le bandeau passe dessous. */
.app-shell:has(> .menu-fab) .readonly-banner {
  margin-top: 62px;
}
@media (min-width: 1024px) {
  .app-shell:has(> .menu-fab) .readonly-banner {
    margin-top: 12px;
  }
}
/* Nouvelle version disponible (service worker) : bandeau fixe au-dessus de la barre du bas. */
.update-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--color-header-bg);
  color: var(--color-header-text);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  font-size: 14px;
}
.update-banner .btn {
  flex: none;
  padding: 6px 12px;
}
@media (min-width: 1024px) {
  .update-banner {
    left: auto;
    right: 24px;
    bottom: 24px;
    max-width: 380px;
  }
}
/* Écrans secondaires : l'en-tête est au-dessus du bandeau, pas de ☰ à éviter. */
.app-shell-sub:has(> .menu-fab) .readonly-banner {
  margin-top: 12px;
}
/* Écriture refusée à l'expiration : le serveur refuse déjà, on grise pour que ce soit clair. */
.is-readonly-disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* --- Cartes : effet de survol et cartes cliquables ---
   Souris uniquement (@media hover) pour ne pas laisser un survol « collé » sur écran tactile ; le léger
   soulèvement est coupé si l'utilisateur a demandé de réduire les animations. */
.balance-card,
.rate-pill,
.dash-kpi,
.dash-panel,
.action-card,
.admin-kpi,
div.admin-card,
.admin-row:not(.admin-row-head) {
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.is-clickable {
  cursor: pointer;
}

.is-clickable:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

@media (hover: hover) {
  .dash-kpi:hover,
  .dash-panel:hover,
  .action-card:hover,
  .admin-kpi:hover,
  div.admin-card:hover,
  .admin-row:not(.admin-row-head):hover {
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
  }

  .balance-card:hover {
    background: rgba(255, 255, 255, 0.13);
  }

  .rate-pill:hover {
    filter: brightness(1.08);
  }
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .balance-card:hover,
  .rate-pill:hover,
  .dash-kpi:hover,
  .dash-panel:hover,
  .action-card:hover,
  .admin-kpi:hover,
  div.admin-card:hover,
  .admin-row:not(.admin-row-head):hover {
    transform: translateY(-3px);
  }

  .is-clickable:active {
    transform: translateY(0) scale(0.99);
  }
}

/* --- Console : inscription d'un changeur --- */
.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.admin-toolbar .admin-title {
  margin: 0;
}

/* Boutons de la console utilisés aussi comme lien ou comme étiquette (choix de fichier). */
a.admin-btn,
label.admin-btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  cursor: pointer;
}

.admin-btn {
  cursor: pointer;
}

.admin-new {
  margin: 0 0 18px;
}

.admin-inline-row {
  display: flex;
  gap: 8px;
}

.admin-inline-row input {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.logo-pick {
  display: flex;
  align-items: center;
  gap: 14px;
}

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

.logo-preview {
  width: 76px;
  height: 76px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px dashed var(--color-border);
  border-radius: 14px;
  background: #fff;
  font-size: 12px;
  color: var(--color-text-muted);
}

.logo-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.admin-created {
  margin: 0 0 18px;
  border-left: 4px solid var(--color-primary);
}

.admin-created p {
  margin: 6px 0;
}

.admin-secret {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  letter-spacing: 0.04em;
  user-select: all;
}

/* Logo de l'entreprise (menu du bureau, reçu). */
.tenant-logo {
  display: block;
  object-fit: contain;
  background: #fff;
}

.side-brand .tenant-logo {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 10px;
  padding: 2px;
}

.receipt-logo {
  display: block;
  max-width: 96px;
  max-height: 72px;
  margin: 0 auto 8px;
  object-fit: contain;
}

/* --- Champ mot de passe avec « œil » (afficher / masquer ce qu'on a tapé) --- */
.password-wrap {
  position: relative;
  display: block;
}

.password-wrap input {
  width: 100%;
  padding-right: 48px;
}

.password-eye {
  position: absolute;
  top: 50%;
  right: 6px;
  width: 38px;
  height: 38px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
}

.password-eye:hover,
.password-eye[aria-pressed="true"] {
  color: var(--color-primary-dark);
}

.password-eye svg {
  width: 20px;
  height: 20px;
}

/* Edge affiche son propre œil dans les champs mot de passe : on garde le nôtre. */
.password-wrap input::-ms-reveal {
  display: none;
}

/* --- Tableaux de bord : panneaux vert foncé et cartes de statistiques --- */
.stat-board {
  background: var(--color-header-bg);
  color: var(--color-header-text);
  border-radius: 24px;
  padding: 14px;
  margin-bottom: 18px;
  box-shadow: 0 10px 30px rgba(22, 35, 27, 0.22);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

@media (min-width: 1024px) {
  .stat-grid {
    grid-template-columns: repeat(var(--stat-cols, 3), minmax(0, 1fr));
  }
}

.stat-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 92px;
  padding: 16px 16px 14px 18px;
  text-align: left;
  font: inherit;
  color: inherit;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(245, 239, 228, 0.12);
  border-radius: 18px;
  transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.stat-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.stat-label {
  font-size: 13px;
  opacity: 0.72;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.stat-sub {
  font-size: 12px;
  opacity: 0.6;
}

/* Pastille d'icône : dégradé selon le sens de l'indicateur. */
.stat-icon {
  flex: none;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  color: #fff;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}

.stat-icon svg {
  width: 22px;
  height: 22px;
}

.stat-icon.is-green { background: linear-gradient(135deg, #1fbf8a, #0b9a6a); }
.stat-icon.is-orange { background: linear-gradient(135deg, #ffb020, #f26a1b); }
.stat-icon.is-red { background: linear-gradient(135deg, #ff5a6a, #e11d48); }
.stat-icon.is-blue { background: linear-gradient(135deg, #38a3ff, #1d6fe0); }
.stat-icon.is-gray { background: linear-gradient(135deg, #7a8a82, #4f5d56); }
.stat-icon.is-gold { background: linear-gradient(135deg, #f6d365, #d9a21b); }

@media (hover: hover) {
  .stat-card:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(245, 239, 228, 0.28);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3);
  }
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .stat-card:hover {
    transform: translateY(-3px);
  }
}

.stat-board-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 2px 10px;
}

.stat-board-head h2 {
  font-size: 15px;
}

.stat-board-head button {
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}

.stat-note {
  margin: -8px 4px 18px;
  font-size: 12px;
  color: var(--color-text-muted);
}

/* --- Carte de confirmation d'une opération (change, vente, dépôt, paiement…) --- */
body.has-confirm {
  overflow: hidden;
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(12, 22, 16, 0.55);
  backdrop-filter: blur(3px);
  animation: confirm-fade 0.2s ease both;
}

.confirm-card {
  width: min(100%, 400px);
  padding: 28px 22px 22px;
  text-align: center;
  background: #fff;
  border-radius: 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  animation: confirm-pop 0.34s cubic-bezier(0.2, 0.9, 0.3, 1.15) both;
}

.confirm-check {
  width: 76px;
  height: 76px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #d9f7e8;
  color: #0b9a6a;
}

.confirm-check svg {
  width: 38px;
  height: 38px;
}

.confirm-check path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: confirm-draw 0.5s 0.2s ease forwards;
}

.confirm-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--color-text);
}

.confirm-ref {
  min-height: 16px;
  margin-top: 2px;
  font: 12px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.05em;
  color: #8a9a92;
}

.confirm-amount {
  margin: 10px 0 2px;
  font-size: 38px;
  font-weight: 800;
  line-height: 1.1;
  color: #0b9a6a;
  overflow-wrap: anywhere;
}

.confirm-caption {
  font-size: 13px;
  color: var(--color-text-muted);
}

.confirm-status {
  margin-top: 8px;
  font-size: 13px;
  color: var(--color-danger);
}

.confirm-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.confirm-row {
  display: flex;
  gap: 10px;
}

.confirm-row .confirm-btn {
  flex: 1;
  min-width: 0;
}

.confirm-btn {
  min-height: 50px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.confirm-btn.is-outline {
  color: var(--color-text);
  background: #fff;
  border: 1px solid var(--color-border);
}

.confirm-btn.is-whatsapp {
  color: #128c4a;
  border-color: #bfe8cf;
}

.confirm-btn.is-whatsapp svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.confirm-btn.is-primary {
  color: #fff;
  border: none;
  background: linear-gradient(135deg, #1fbf8a, #0b9a6a);
  box-shadow: 0 10px 22px rgba(11, 154, 106, 0.35);
}

.confirm-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

@media (hover: hover) {
  .confirm-btn.is-outline:hover {
    background: #f6f3ea;
  }

  .confirm-btn.is-primary:hover {
    box-shadow: 0 12px 26px rgba(11, 154, 106, 0.45);
  }
}

@keyframes confirm-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes confirm-pop {
  from { opacity: 0; transform: translateY(14px) scale(0.92); }
  to { opacity: 1; transform: none; }
}

@keyframes confirm-draw {
  to { stroke-dashoffset: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .confirm-overlay,
  .confirm-card {
    animation: none;
  }

  .confirm-check path {
    animation: none;
    stroke-dashoffset: 0;
  }
}
