:root {
  --bg: #0f1419;
  --card: #1a2330;
  --ctrl-bg: #0f1419;
  --text: #e8eef6;
  --muted: #9aa8b8;
  --accent: #3d8bfd;
  --danger: #f87171;
  --line: #2a3646;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.home-body { padding: 2.5rem 1rem 3.5rem; }
.home-wrap { width: min(920px, 100%); margin: 0 auto; }
.home-hero {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.4rem 1.5rem 1.6rem;
  margin: 0 0 1.25rem;
}
.home-hero h1 { font-size: 1.35rem; margin: 0 0 .6rem; font-weight: 650; }
.home-hero p { margin: 0 0 .85rem; }
.home-cta { margin-top: .35rem; }
.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
  margin: 1.25rem 0;
}
@media (max-width: 800px) {
  .home-grid { grid-template-columns: 1fr; }
}
.home-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem;
}
.home-card h2 { margin: 0 0 .4rem; font-size: 1.05rem; }
.home-card p { margin: 0; color: #d5deea; }
.home-legal {
  font-size: .92rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 1.1rem;
  margin-top: 1.4rem;
}
.home-legal a { color: var(--accent); }

.auth-stack {
  width: min(100%, 38rem);
}
.portal-brand {
  margin: 0 0 1.35rem;
  text-align: center;
}
.portal-name {
  display: block;
  color: #fff;
  font-size: 2.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.15;
}
.portal-tagline {
  display: block;
  margin-top: 0.35rem;
  color: #9aa4f0;
  font-size: 1.02rem;
  font-weight: 500;
  line-height: 1.3;
}
.card {
  background: var(--card);
  padding: 1.75rem;
  border-radius: 12px;
  border: 1px solid var(--line);
}
h1 { margin: 0 0 0.35rem; font-size: 1.35rem; }
label { display: block; margin: 0.9rem 0 0.35rem; font-size: 0.9rem; }
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--ctrl-bg, var(--card));
  color: var(--text);
}
input[type="checkbox"],
input[type="radio"] {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
  background: transparent;
  border: 0;
}
button,
a.btn {
  display: block;
  width: 100%;
  margin-top: 1.2rem;
  padding: 0.7rem;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
}
button.danger,
button[class~="danger"] {
  background: #b42318 !important;
  color: #fff !important;
}
button.danger:hover {
  background: #8f1b12 !important;
}
a.btn-2fa,
a.btn-2fa-off {
  background: #b42318 !important;
  color: #fff !important;
  width: auto;
}
a.btn-2fa-on {
  background: #166534 !important;
  color: #fff !important;
  width: auto;
}
.totp-help h3 {
  margin: 1.1rem 0 0.35rem;
  font-size: 1.05rem;
}
.totp-help p {
  margin: 0;
  line-height: 1.45;
}
.totp-status {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  text-align: center;
  font-weight: 650;
}
.totp-status-on {
  background: #16321f;
  color: #86efac;
  border: 1px solid #166534;
}
.totp-status-off {
  background: #3a1d1d;
  color: #fca5a5;
  border: 1px solid #b42318;
}
.muted { color: var(--muted); font-size: 0.9rem; }
.alert {
  background: #3a1d1d;
  color: var(--danger);
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.top.hub-top {
  border-bottom: 0;
  background: linear-gradient(to bottom, rgba(63, 76, 107, 1), #0f1419);
}
.hub-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: #fff;
  text-decoration: none;
}
.hub-brand strong,
.q-brand strong,
.app-brand-title {
  font-family: berlin, sans-serif;
  font-size: 2rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.1;
}
.top a { color: var(--accent); }
.impersonate-bar {
  background: #b7791f;
  color: #fff;
  padding: 0.45rem 1.25rem;
  font-size: 0.92rem;
}
.impersonate-bar a { color: #fff; font-weight: 700; }
.wrap { padding: 1.25rem; max-width: 44rem; margin: auto; }
.wrap-hub,
.wrap-full { max-width: none; width: 100%; box-sizing: border-box; }
.admin-hub-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
  margin-top: 1rem;
}
.admin-hub-grid .btn { width: 100%; margin: 0; text-align: center; }
@media (max-width: 800px) {
  .admin-hub-grid { grid-template-columns: 1fr 1fr; }
}
.app-list li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.app-list {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.9rem;
}
.app-list a { color: var(--text); font-weight: 600; }
.app-card {
  text-align: center;
}
.app-card-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
}
.app-icon {
  width: 128px;
  height: 128px;
  object-fit: cover;
  border-radius: 28px;
  border: 0;
  background: transparent;
}
.app-icon-fallback {
  display: grid;
  place-items: center;
  font-size: 2.6rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(145deg, #3d8bfd, #1e3a5f);
}
.q-userchip { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 650; }
.top-actions { display: flex; align-items: center; gap: 0.7rem; margin-left: auto; }
a.btn-admin {
  width: fit-content;
  margin: 0;
  background: #1e3a5f;
  color: #fff;
}
.user-avatar {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  vertical-align: middle;
  background: #0f1419;
}
.user-avatar-list { width: 48px; height: 48px; max-width: 48px; max-height: 48px; object-fit: cover; }
.rolodex { display: flex; flex-wrap: wrap; gap: 0.28rem; margin: 0.4rem 0 1rem; }
.rolodex .btn { width: fit-content; margin: 0; padding: 0.28rem 0.5rem; }
.rolodex .btn.is-on { background: #1e3a5f; color: #fff; }
.rolodex .btn.is-empty { opacity: 0.35; }
.user-avatar-lg {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0f1419;
}
.app-icon-sm {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  font-size: 1rem;
}
.app-card-name { font-size: 1rem; }
.wrap-wide { max-width: 56rem; }
.nav { display: flex; gap: 1rem; align-items: center; }
.nav a { color: var(--accent); }
.table { width: 100%; border-collapse: collapse; margin: 1rem 0 2rem; }
.table th, .table td { text-align: left; padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--line); }
.table a { color: var(--accent); }
.card-form {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.25rem;
  max-width: 28rem;
}
.card-form button { width: auto; min-width: 0; }
.users-filter button { width: auto; min-width: 0; margin-top: 0.8rem; }
.users-bulk {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0 0 1.5rem;
}
.users-bulk button {
  display: inline-block !important;
  width: auto !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 0.45rem 0.85rem !important;
}
.priv-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
}
.priv-btn {
  display: inline-block !important;
  width: auto !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 0.18rem 0.5rem !important;
  border: 1px solid #c5cdd6 !important;
  border-radius: 0.25rem !important;
  background: transparent !important;
  color: #c5cdd6 !important;
  font-size: 0.75rem !important;
  font-weight: 600 !important;
  line-height: 1.2 !important;
  cursor: pointer;
}
.priv-btn.is-on {
  background: #198754 !important;
  border-color: #198754 !important;
  color: #fff !important;
}
.priv-btn.is-busy { opacity: 0.55; pointer-events: none; }
.priv-btn.is-admin, .priv-btn.is-app-admin {
  background: #e67e22 !important;
  border-color: #e67e22 !important;
  color: #fff !important;
}
.users-apps-view { margin: 0 0 1rem; }
.users-apps-view .btn { width: fit-content; }
.check { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.9rem; }
.check input { width: auto; }
.ok {
  background: #16321f;
  color: #86efac;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
}
.inline { display: inline; }
.inline button { width: auto; margin: 0; padding: 0.35rem 0.7rem; font-size: 0.85rem; }
select {
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #0f1419;
  color: var(--text);
}
.auth-link {
  display: inline-block;
  margin-top: 1rem;
  color: var(--accent);
  font-size: 0.9rem;
}
.auth-links {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.card-wide { width: min(100%, 26rem); }
.tabs { display: flex; gap: 0.75rem; margin: 1rem 0; }
.tabs a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.tabs a.is-active { color: var(--text); background: var(--card); }
.badge {
  display: inline-block;
  background: #3a2e12;
  color: #fbbf24;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-size: 0.8rem;
}
.table th a { color: var(--text); text-decoration: none; }
.table th a:hover { color: var(--accent); }
.tag {
  display: inline-block;
  margin: 0 0.2rem 0.2rem 0;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #121a24;
  color: var(--muted);
  font-size: 0.75rem;
}
h2 { font-size: 1.1rem; margin-top: 2rem; }
.btn {
  display: inline-block;
  margin-right: 0.5rem;
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}
a.q-exit,
a.btn-danger.q-exit {
  display: inline-block !important;
  width: auto !important;
  margin: 0 !important;
  padding: 0.4rem 0.85rem !important;
  background: #dc3545 !important;
  color: #fff !important;
  border: 1px solid #dc3545 !important;
  border-radius: 8px;
  font-weight: 700 !important;
  font-size: 0.9rem !important;
  text-decoration: none !important;
  line-height: 1.3 !important;
}
a.q-exit:hover,
a.btn-danger.q-exit:hover {
  background: #bb2d3b !important;
  border-color: #b02a37 !important;
  color: #fff !important;
}
a.btn-2fa-on.q-exit,
a.btn-2fa-on.q-exit:hover {
  background: #166534 !important;
  border: 1px solid #166534 !important;
  border-color: #166534 !important;
  color: #fff !important;
}
a.btn-2fa-off.q-exit,
a.btn-2fa-off.q-exit:hover {
  background: #b42318 !important;
  border: 1px solid #b42318 !important;
  border-color: #b42318 !important;
  color: #fff !important;
}

.lang-flags {
  display: flex;
  justify-content: center;
  gap: 0.45rem;
  margin-top: 0.7rem;
}
.lang-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  padding: 0.15rem;
  border-radius: 0.3rem;
  border: 1px solid transparent;
  line-height: 1;
  text-decoration: none;
  opacity: 0.55;
}
.lang-flag img {
  display: block;
  width: 24px;
  height: 16px;
  object-fit: cover;
}
.hub-lang-flags { justify-content: flex-start; margin: 0 0 0.8rem; }
.lang-flag.is-on {
  opacity: 1;
  border-color: var(--line);
  background: color-mix(in srgb, var(--card) 75%, white);
}

.hub-pending {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: fit-content;
  padding: 0.25rem 0.55rem;
  border-radius: 0.3rem;
  color: #fff;
  text-decoration: none;
  background: color-mix(in srgb, var(--card) 55%, transparent);
}
.hub-pending-icon { display: block; flex: 0 0 auto; }
.hub-pending span { font-weight: 700; line-height: 1; }

.users-panel { margin-bottom: 1rem; }
.users-filters, .users-display, .users-actions {
  display: flex; flex-wrap: wrap; align-items: end; gap: 0.7rem 1rem;
  padding: 0.7rem 0.8rem; margin-bottom: 0.6rem;
  background: color-mix(in srgb, var(--card, #fff) 92%, #d7dde6);
  border: 1px solid var(--line, #d7dde6); border-radius: 0.4rem;
}
.users-filters strong, .users-display strong, .users-actions strong { align-self: center; }
.users-filters label, .users-actions label { display: flex; flex-direction: column; gap: 0.2rem; width: fit-content; }
.users-filters select, .users-filters input, .users-actions select { width: fit-content; min-width: 10rem; }
.users-display .rolodex { margin: 0; }
.users-as { width: fit-content !important; padding: 0.15rem 0.4rem !important; font-size: 0.75rem !important; }
.users-new { width: fit-content !important; background: #198754 !important; border-color: #198754 !important; color: #fff !important; }
.user-edit { text-align: left; }
.user-photo { position: relative; width: 72px; height: 72px; margin-bottom: 0.6rem; cursor: pointer; }
.user-photo img, .user-photo span { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; display: grid; place-items: center; background: #e7eef6; }
.user-photo-x { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: #dc3545; color: #fff; line-height: 22px; padding: 0; }
.user-fields label { display: block; margin: 0.35rem 0; }
.user-fields input, .user-fields textarea { width: 100%; }
.user-apps { margin-top: 0.8rem; }
.priv-btn.is-app-admin { background: #e67e22 !important; border-color: #e67e22 !important; color: #fff !important; }

.swal2-popup { background: #1c2430 !important; color: #e8eef6 !important; }
.swal2-popup .swal2-title, .swal2-popup .swal2-html-container { color: #e8eef6 !important; }
.user-fields input, .user-fields textarea {
  background: #fff !important; color: #1a1a1a !important; border: 1px solid #c5ced8 !important;
}
.user-2fa { margin: 0.4rem 0; }

.user-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem 1.2rem; }
.user-col label { display: block; margin: 0.35rem 0; }
.swal2-popup .user-edit label.check { display: flex; flex-direction: row; align-items: center; gap: 0.45rem; width: fit-content; }
.swal2-popup .user-edit label.check input { width: auto !important; order: 0; }
.swal2-popup .user-edit label.check span { order: 1; }

/* Boutons site-wide */
.btn_small {
    padding-top: 0.2em !important;
    padding-bottom: 0.4em !important;
    font-weight: 400 !important;
    border-radius: 5px !important;
    font-size: 0.8em !important;
    width: fit-content !important;
    white-space: nowrap !important;
}
.btn_small:disabled, .btn_small.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.login-note {
  margin: 0.8rem 0 1rem;
  padding: 0.7rem 0.8rem;
  background: rgba(220, 38, 38, 0.3);
  border: 1px dashed rgba(220, 38, 38, 1);
  border-radius: 10px;
  text-align: justify;
  font-size: 0.7em;
}
.login-resend { display: flex; justify-content: center; margin: 0.6rem 0 0; }

.card-code { width: 22rem; max-width: 100%; }
.digicode { display: flex; align-items: center; gap: 0.35rem; margin: 0.8rem 0 1rem; }
.digicode .digit {
  width: 2.2rem; height: 2.6rem; text-align: center; font-size: 1.2rem;
  padding: 0; border-radius: 8px;
}
.buoy {
  width: 2.6rem; height: 2.6rem; padding: 0; border: 0; border-radius: 8px;
  background: #dc2626; color: #fff; display: grid; place-items: center;
}
.backup { width: 100%; margin: 0.8rem 0 1rem; }
