/* BetaHub — feuille de style unique, mobile-first, sans dépendance externe. */
:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --success: #047857;
    --success-bg: #ecfdf5;
    --error: #b91c1c;
    --error-bg: #fef2f2;
    --info: #0369a1;
    --info-bg: #f0f9ff;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .18);
}

* { 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, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Barre supérieure ---------- */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .75rem 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem .75rem;
    position: sticky;
    top: 0;
    z-index: 10;
}
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--primary); }
.nav { display: flex; gap: .5rem; flex-wrap: wrap; flex: 1 1 100%; order: 3; }
.nav a {
    font-size: .9rem;
    color: var(--muted);
    padding: .4rem .6rem;
    border-radius: 999px;
}
.nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.topbar-user { display: flex; align-items: center; gap: .75rem; margin-left: auto; }
.who { font-size: .85rem; color: var(--muted); max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
form.inline { display: inline; margin: 0; }
.link-button {
    background: none; border: 0; padding: 0; font: inherit; font-size: .85rem;
    color: var(--muted); cursor: pointer; text-decoration: underline;
}

@media (min-width: 720px) {
    .topbar { padding: .9rem 1.5rem; flex-wrap: nowrap; }
    .nav { flex: 1 1 auto; order: 0; justify-content: center; }
    .nav a { font-size: .95rem; }
}

/* ---------- Conteneur ---------- */
.page { width: 100%; max-width: 56rem; margin: 0 auto; padding: 1rem 1rem 2rem; flex: 1; }
@media (min-width: 720px) { .page { padding: 1.75rem 1.5rem 3rem; } }

h1 { font-size: 1.4rem; line-height: 1.25; margin: 0 0 .35rem; }
h2 { font-size: 1.1rem; margin: 1.75rem 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .35rem; }
p { margin: 0 0 .85rem; }
.lead { color: var(--muted); margin-bottom: 1.25rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tiny { font-size: .78rem; }
.center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.75rem; }

/* ---------- Cartes ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem;
    margin-bottom: 1rem;
}
.card-narrow { max-width: 26rem; margin-left: auto; margin-right: auto; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.card + .card { margin-top: .85rem; }

/* ---------- Formulaires ---------- */
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
.field .hint { display: block; font-size: .78rem; color: var(--muted); margin-top: .3rem; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=tel], textarea, select {
    width: 100%;
    padding: .7rem .8rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 16px; /* évite le zoom automatique iOS */
}
input:focus, textarea:focus, select:focus {
    outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent);
    outline-offset: 1px;
    border-color: var(--primary);
}
textarea { min-height: 6.5rem; resize: vertical; }
input.code-input {
    font-size: 1.6rem;
    letter-spacing: .5em;
    text-align: center;
    font-variant-numeric: tabular-nums;
    padding: .8rem;
}
.field-error { color: var(--error); font-size: .82rem; margin-top: .3rem; }
.checkbox { display: flex; align-items: flex-start; gap: .6rem; margin-bottom: .6rem; }
.checkbox input { width: 1.15rem; height: 1.15rem; margin-top: .15rem; flex: 0 0 auto; }
.checkbox label { font-weight: 500; font-size: .92rem; margin: 0; }

/* ---------- Boutons ---------- */
.button {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    background: var(--primary); color: #fff; border: 1px solid var(--primary);
    padding: .75rem 1.1rem; border-radius: 10px; font: inherit; font-weight: 600;
    font-size: .95rem; cursor: pointer; text-decoration: none;
    min-height: 44px; /* cible tactile confortable */
}
.button:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.button:disabled { opacity: .55; cursor: not-allowed; }
.button-block { width: 100%; }
.button-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.button-secondary:hover { background: var(--bg); color: var(--text); }
.button-danger { background: #fff; color: var(--error); border-color: #fecaca; }
.button-danger:hover { background: var(--error-bg); color: var(--error); }
.button-small { padding: .45rem .7rem; font-size: .85rem; min-height: 36px; }
.button-row { display: flex; flex-wrap: wrap; gap: .6rem; }
.button-row .button { flex: 1 1 auto; }
@media (min-width: 720px) { .button-row .button { flex: 0 0 auto; } }

/* ---------- Alertes ---------- */
.alert {
    border-radius: 12px; padding: .8rem 1rem; margin-bottom: 1rem;
    font-size: .92rem; border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); color: var(--success); border-color: #a7f3d0; }
.alert-error { background: var(--error-bg); color: var(--error); border-color: #fecaca; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: #bae6fd; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }

/* ---------- Badges / puces ---------- */
.badge {
    display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .02em;
    padding: .18rem .5rem; border-radius: 999px; background: var(--bg); color: var(--muted);
    border: 1px solid var(--border); white-space: nowrap;
}
.badge-active { background: var(--success-bg); color: var(--success); border-color: #a7f3d0; }
.badge-invited { background: var(--info-bg); color: var(--info); border-color: #bae6fd; }
.badge-revoked { background: var(--error-bg); color: var(--error); border-color: #fecaca; }

/* ---------- Listes ---------- */
.stack { display: flex; flex-direction: column; gap: .85rem; }
.list-item {
    display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem;
    padding: .9rem 0; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: 0; }
.list-item .meta { font-size: .82rem; color: var(--muted); }

/* ---------- Données (identifiant, mot de passe) ---------- */
.secret-row {
    display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
    background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
    padding: .55rem .65rem;
}
.secret-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .95rem; flex: 1 1 8rem; min-width: 0;
    overflow-wrap: anywhere; word-break: break-all;
}
.secret-value.is-hidden { letter-spacing: .2em; color: var(--muted); }
.url-box { overflow-wrap: anywhere; word-break: break-all; }

/* ---------- Statistiques ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .85rem; }
.stat .value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat .label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, 1fr); } }

/* ---------- Tableau d'audit ---------- */
.audit { list-style: none; padding: 0; margin: 0; font-size: .85rem; }
.audit li { padding: .45rem 0; border-bottom: 1px dashed var(--border); display: flex; gap: .5rem; justify-content: space-between; }
.audit li:last-child { border-bottom: 0; }
.audit .when { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Pied de page ---------- */
.footer {
    border-top: 1px solid var(--border); background: var(--surface);
    padding: 1rem; font-size: .78rem; color: var(--muted);
    display: flex; flex-wrap: wrap; gap: .5rem; justify-content: space-between;
    max-width: 100%;
}
@media (min-width: 720px) { .footer { padding: 1rem 1.5rem; } }

/* ---------- Divers ---------- */
.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;
}
.divider { height: 1px; background: var(--border); margin: 1.25rem 0; border: 0; }
details > summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
details { margin-top: .5rem; }
.pre-wrap { white-space: pre-wrap; }
@media (prefers-reduced-motion: no-preference) {
    .button, .card { transition: background-color .15s ease, box-shadow .15s ease; }
}
