/* ==========================================================================
   DataSearch — Feuille de styles unique (fusion de tous les <style> inline).
   Palette "GitHub-dark", Inter + JetBrains Mono.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0a0c10;
    --ink: #0a0c10;
    --surface: #0f1117;
    --panel: #0f1117;
    --surface2: #161b22;
    --border: #21262d;
    --line: #21262d;
    --border-h: #30363d;
    --line-h: #30363d;
    --text: #c9d1d9;
    --paper: #c9d1d9;
    --muted: #6e7681;
    --accent: #58a6ff;
    --signal: #58a6ff;
    --green: #3fb950;
    --red: #f85149;
    --orange: #ffa657;
    --stamp: #d29922;
    --purple: #d2a8ff;
    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
    --radius: 8px;
}

html, body {
    width: 100%; min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
}
body {
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding-bottom: 80px;
}
body.auth-body {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 20px;
}

/* ==========================================================================
   Header / Nav commun aux pages authentifiées (fin + hamburger mobile)
   ========================================================================== */
.header {
    padding: 8px 20px;
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0;
    background: rgba(10,12,16,0.95);
    backdrop-filter: blur(10px);
    z-index: 100;
    min-height: 44px;
}
.header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-nav {
    display: flex; align-items: center; gap: 2px;
}
.logo {
    font-family: var(--font-mono); font-size: 14px; font-weight: 500;
    color: var(--accent); letter-spacing: -0.02em; text-decoration: none;
    white-space: nowrap; flex-shrink: 0;
}
.logo span { color: var(--muted); }
.header-sep { color: var(--border); margin: 0 2px; flex-shrink: 0; }
.nav-link {
    font-size: 13px; color: var(--muted); text-decoration: none;
    padding: 5px 10px; border-radius: 6px;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
}
.nav-link:hover { color: var(--text); background: var(--surface2); }
.nav-link.active { color: var(--text); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.header-stats {
    display: flex; align-items: center; gap: 6px;
    font-family: var(--font-mono); font-size: 11px;
    padding-right: 10px; border-right: 1px solid var(--border);
}
.stat-total { color: var(--accent); font-weight: 700; font-size: 13px; letter-spacing: -0.02em; }
.stat-label { color: var(--muted); font-size: 10px; }
.user-chip {
    font-family: var(--font-mono); font-size: 11px; color: var(--muted);
    background: var(--surface2); border: 1px solid var(--border);
    padding: 3px 9px; border-radius: 20px; white-space: nowrap;
}
.user-chip strong { color: var(--text); }
.credits-chip {
    font-family: var(--font-mono); font-size: 11px;
    padding: 3px 9px; border-radius: 20px;
    border: 1px solid; white-space: nowrap;
}
.credits-chip.ok   { color: var(--green);  border-color: rgba(63,185,80,0.3);  background: rgba(63,185,80,0.07); }
.credits-chip.low  { color: var(--orange); border-color: rgba(255,166,87,0.3); background: rgba(255,166,87,0.07); }
.credits-chip.none { color: var(--red);    border-color: rgba(248,81,73,0.3);  background: rgba(248,81,73,0.07); }
.credits-chip.unlimited { color: var(--purple); border-color: rgba(210,168,255,0.3); background: rgba(210,168,255,0.08); font-weight: 600; }
.badge-admin {
    font-family: var(--font-mono); font-size: 10px; font-weight: 600;
    color: var(--purple); background: rgba(210,168,255,0.1);
    border: 1px solid rgba(210,168,255,0.25);
    padding: 2px 8px; border-radius: 20px; letter-spacing: 0.04em; white-space: nowrap;
}
.btn-logout {
    font-size: 12px; font-weight: 500; color: var(--muted);
    background: transparent; border: 1px solid var(--border);
    border-radius: 6px; padding: 4px 11px; cursor: pointer;
    text-decoration: none; white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}
.btn-logout:hover { color: var(--red); border-color: rgba(248,81,73,0.4); }

/* Hamburger (caché sur desktop, visible sur mobile) */
.nav-toggle {
    display: none;
    flex-direction: column; justify-content: center; gap: 4px;
    width: 30px; height: 30px;
    background: transparent; border: 1px solid var(--border); border-radius: 6px;
    cursor: pointer; padding: 0 6px;
}
.nav-toggle span {
    display: block; height: 2px; width: 100%;
    background: var(--text); border-radius: 1px;
    transition: transform 0.2s, opacity 0.2s;
}
.header.nav-open .nav-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.header.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
.header.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ==========================================================================
   Landing page (home)
   ========================================================================== */
nav {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center;
    padding: 16px 32px;
    border-bottom: 1px solid var(--line);
    background: rgba(10,12,16,0.9);
    backdrop-filter: blur(10px);
}
.nav-logo {
    font-family: var(--font-mono); font-size: 15px; font-weight: 500;
    letter-spacing: -0.02em; color: var(--signal); text-decoration: none;
}
.nav-logo span { color: var(--muted); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.btn-nav {
    font-size: 13px; font-weight: 500; text-decoration: none;
    padding: 7px 16px; border-radius: 6px;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.btn-nav-ghost { color: var(--muted); border: 1px solid transparent; }
.btn-nav-ghost:hover { color: var(--paper); background: var(--panel); }
.btn-nav-fill { color: var(--ink); background: var(--signal); font-weight: 600; }
.btn-nav-fill:hover { background: #79c0ff; }

.hero {
    max-width: 1080px; margin: 0 auto;
    padding: 88px 32px 80px;
    display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 56px;
    align-items: center;
}
.hero-eyebrow {
    font-family: var(--font-mono); font-size: 12px; font-weight: 500;
    letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--muted); margin-bottom: 18px;
}
.hero-title {
    font-size: clamp(34px, 4.4vw, 50px); font-weight: 800;
    line-height: 1.12; letter-spacing: -0.03em;
    color: #e6edf3; margin-bottom: 20px;
}
.hero-sub { font-size: 16px; line-height: 1.65; color: var(--muted); max-width: 480px; margin-bottom: 36px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 28px; }
.btn-cta {
    font-size: 14px; font-weight: 600; text-decoration: none;
    padding: 12px 24px; border-radius: 8px;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn-cta-primary { background: var(--signal); color: var(--ink); border: 1px solid var(--signal); }
.btn-cta-primary:hover { background: #79c0ff; }
.btn-cta-primary:active { transform: scale(0.98); }
.btn-cta-secondary { background: transparent; color: var(--paper); border: 1px solid var(--line-h); }
.btn-cta-secondary:hover { background: var(--panel); }
.hero-note { font-size: 12.5px; color: var(--muted); }

.console { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.console-bar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.console-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-h); }
.console-name { margin-left: 8px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); letter-spacing: 0.02em; }
.console-body { padding: 16px 18px; font-family: var(--font-mono); font-size: 13px; }
.console-row {
    display: flex; align-items: baseline; gap: 10px;
    padding: 5px 0; opacity: 0;
    animation: console-in 0.4s ease-out forwards;
}
.console-row .k::before { content: '›'; color: var(--line-h); margin-right: 8px; }
.console-row .k { color: var(--muted); }
.console-divider { height: 1px; background: var(--line); margin: 8px 0; }
.console-total { padding-top: 6px; }
.console-total .k { color: var(--muted); }
.console-total .v { color: var(--stamp); font-weight: 600; }
.cursor {
    display: inline-block; width: 7px; height: 14px; margin-left: 6px;
    background: var(--stamp); vertical-align: -2px;
    animation: cursor-blink 1s step-end infinite;
}
@keyframes console-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes cursor-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
    .console-row { animation: none; opacity: 1; }
    .cursor { animation: none; }
}

.features { max-width: 1080px; margin: 0 auto; padding: 0 32px 96px; }
.features-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
    background: var(--line); border: 1px solid var(--line);
    border-radius: 12px; overflow: hidden;
}
.feat { background: var(--panel); padding: 30px 28px; }
.feat-tag { font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; color: var(--signal); letter-spacing: 0.02em; margin-bottom: 14px; }
.feat-title { font-size: 16px; font-weight: 700; color: #e6edf3; margin-bottom: 8px; }
.feat-text { font-size: 13.5px; color: var(--muted); line-height: 1.6; }

footer {
    border-top: 1px solid var(--line);
    padding: 24px 32px;
    display: flex; align-items: center; justify-content: space-between;
    max-width: 1080px; margin: 0 auto;
}
.footer-brand { font-family: var(--font-mono); font-size: 13px; color: var(--muted); text-decoration: none; }
.footer-brand span { color: var(--line-h); }
.footer-links { display: flex; gap: 20px; }
.footer-links a { font-size: 13px; color: var(--muted); text-decoration: none; transition: color 0.15s; }
.footer-links a:hover { color: var(--paper); }

@media (max-width: 860px) {
    .hero { grid-template-columns: 1fr; padding: 56px 24px 64px; }
    .features { padding: 0 24px 64px; }
    .features-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    nav { padding: 14px 20px; }
    footer { flex-direction: column; gap: 14px; text-align: center; padding: 24px 20px; }
}

/* ==========================================================================
   Auth (login / register)
   ========================================================================== */
.brand {
    font-family: var(--font-mono); font-size: 18px; font-weight: 500;
    color: var(--accent); letter-spacing: -0.02em; margin-bottom: 32px;
    text-decoration: none;
}
.brand span { color: var(--muted); }
.card {
    width: 100%;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 12px; padding: 22px 24px;
}
.auth-body .card { max-width: 380px; padding: 32px; }
.card-title { font-size: 20px; font-weight: 700; color: #e6edf3; margin-bottom: 6px; }
.card-sub { font-size: 13px; color: var(--muted); margin-bottom: 28px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 6px; letter-spacing: 0.04em; text-transform: uppercase; }
.field input {
    width: 100%; background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; padding: 10px 14px; outline: none;
    font-family: var(--font-mono); font-size: 13px; color: var(--text);
    transition: border-color 0.15s;
}
.field input:focus { border-color: var(--accent); }
.field input::placeholder { color: var(--muted); font-family: var(--font-ui); }
.btn-submit {
    width: 100%; margin-top: 8px;
    background: var(--accent); color: #0a0c10;
    border: none; border-radius: 8px; padding: 11px;
    font-family: var(--font-ui); font-size: 14px; font-weight: 600;
    cursor: pointer; transition: background 0.15s;
}
.btn-submit:hover { background: #79c0ff; }
.error, .success {
    background: rgba(248,81,73,0.08); border: 1px solid rgba(248,81,73,0.25);
    color: var(--red); border-radius: 8px; padding: 10px 14px;
    font-size: 13px; margin-bottom: 20px;
}
.success { background: rgba(63,185,80,0.08); border-color: rgba(63,185,80,0.25); color: var(--green); }
.footer-link { text-align: center; margin-top: 20px; font-size: 13px; color: var(--muted); }
.footer-link a { color: var(--accent); text-decoration: none; }
.footer-link a:hover { text-decoration: underline; }

/* ==========================================================================
   Dashboard — recherche
   ========================================================================== */
.search-zone { max-width: 1400px; margin: 48px auto 0; padding: 0 20px; }
.search-title { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; color: #e6edf3; margin-bottom: 8px; }
.search-title span { color: var(--accent); }
.search-sub { font-size: 14px; color: var(--muted); margin-bottom: 28px; }

.criteria-box { background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.criteria-hint { font-size: 11px; color: var(--muted); font-family: var(--font-mono); }
#criteria-root { padding: 12px; }

.ast-group { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); margin: 6px 0; overflow: hidden; }
.ast-group.is-root { border-color: var(--border-h); background: var(--surface2); }
.ast-group-header { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); background: rgba(0,0,0,0.18); flex-wrap: wrap; }
.ast-group.is-root > .ast-group-header { background: transparent; }
.ast-op { font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; padding: 4px 12px; border-radius: 14px; border: 1px solid; cursor: pointer; text-transform: uppercase; transition: all 0.15s; user-select: none; }
.ast-op.and { color: var(--accent); border-color: rgba(88,166,255,0.4); background: rgba(88,166,255,0.08); }
.ast-op.or  { color: var(--purple); border-color: rgba(210,168,255,0.4); background: rgba(210,168,255,0.08); }
.ast-op:hover { filter: brightness(1.15); }
.ast-group-label { font-size: 11px; color: var(--muted); font-family: var(--font-mono); }
.ast-group-actions { display: flex; gap: 6px; margin-left: auto; }
.ast-btn { font-size: 11px; font-weight: 500; color: var(--muted); background: transparent; border: 1px solid var(--border); border-radius: 6px; padding: 4px 9px; cursor: pointer; transition: color 0.15s, border-color 0.15s; white-space: nowrap; }
.ast-btn:hover { color: var(--text); border-color: var(--border-h); }
.ast-btn.danger:hover { color: var(--red); border-color: rgba(248,81,73,0.4); }
.ast-group-body { padding: 8px 10px 10px 16px; display: flex; flex-direction: column; gap: 6px; }
.ast-group.is-root > .ast-group-body { padding: 10px 12px 12px; }
.ast-connector { position: relative; }
.ast-connector::before { content: ''; position: absolute; left: -8px; top: -3px; bottom: 50%; width: 2px; background: var(--border-h); }
.ast-connector:first-child::before { display: none; }

.criterion-row { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; min-height: 42px; background: var(--surface2); transition: border-color 0.1s; }
.criterion-row:focus-within { border-color: var(--accent); }
.criterion-val { flex: 1; background: transparent; border: none; outline: none; font-family: var(--font-mono); font-size: 13px; color: var(--text); padding: 10px 14px; min-width: 0; }
.criterion-val::placeholder { color: var(--muted); font-family: var(--font-ui); font-size: 13px; }
.btn-remove { background: transparent; border: none; color: var(--muted); font-size: 18px; line-height: 1; padding: 0 12px; cursor: pointer; transition: color 0.15s; flex-shrink: 0; }
.btn-remove:hover { color: var(--red); }
.btn-remove.invisible { visibility: hidden; }
.criteria-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 12px; border-top: 1px solid var(--border); background: rgba(0,0,0,0.15); }
.btn-add { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--muted); background: transparent; border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px; cursor: pointer; transition: color 0.15s, border-color 0.15s; }
.btn-add:hover { color: var(--text); border-color: var(--border-h); }
.btn-search { font-size: 13px; font-weight: 600; background: var(--accent); color: #0a0c10; border: none; border-radius: 6px; padding: 8px 22px; cursor: pointer; transition: background 0.15s, transform 0.1s; white-space: nowrap; }
.btn-search:hover  { background: #79c0ff; }
.btn-search:active { transform: scale(0.97); }
.btn-search:disabled { background: var(--border-h); color: var(--muted); cursor: not-allowed; transform: none; }

.no-credits-banner { max-width: 1400px; margin: 20px auto 0; padding: 0 20px; }
.no-credits-inner { background: rgba(248,81,73,0.07); border: 1px solid rgba(248,81,73,0.25); color: var(--red); border-radius: 8px; padding: 12px 18px; font-size: 13px; }

.stats-bar { max-width: 1400px; margin: 20px auto 0; padding: 0 20px; font-size: 12px; color: var(--muted); font-family: var(--font-mono); display: flex; gap: 16px; align-items: center; }
.stats-bar .count { color: var(--accent); font-weight: 500; }
.stats-bar .sep   { color: var(--border); }
.export-bar { max-width: 1400px; margin: 12px auto 0; padding: 0 20px; display: flex; gap: 10px; align-items: center; font-size: 13px; }
.export-bar .export-label { color: var(--muted); font-weight: 500; }
.export-bar .export-sep { color: var(--border); }
.btn-export { background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 6px 14px; border-radius: 8px; font-size: 13px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; transition: border-color .15s, background .15s; }
.btn-export:hover { border-color: var(--accent); background: var(--surface2); }
.btn-export-server { color: var(--accent); }
.stats-tag { padding: 2px 7px; border-radius: 4px; border: 1px solid var(--border); color: var(--muted); }

.loading { max-width: 1400px; margin: 48px auto 0; padding: 0 20px; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; font-family: var(--font-mono); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-box { max-width: 1400px; margin: 32px auto 0; padding: 0 20px; }
.error-inner { background: rgba(248,81,73,0.07); border: 1px solid rgba(248,81,73,0.2); color: var(--red); border-radius: var(--radius); padding: 14px 18px; font-size: 13px; font-family: var(--font-mono); display: flex; align-items: center; gap: 10px; }

.results { max-width: 1400px; margin: 32px auto 0; padding: 0 20px; display: flex; flex-direction: column; gap: 32px; }
.source-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.source-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.source-name { font-size: 13px; font-weight: 600; color: #e6edf3; }
.source-count { font-family: var(--font-mono); font-size: 11px; color: var(--muted); background: var(--surface2); border: 1px solid var(--border); padding: 2px 8px; border-radius: 20px; margin-left: auto; }
.table-sub { margin-bottom: 14px; }
.table-sub-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.table-sub-name { font-family: var(--font-mono); font-size: 11px; color: var(--muted); text-transform: lowercase; }
.table-sub-count { font-size: 10px; color: var(--muted); }
.result-cards { display: flex; flex-direction: column; gap: 10px; }
.result-card { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid; border-radius: var(--radius); overflow: hidden; transition: border-color 0.15s; }
.result-card:hover { border-color: var(--border-h); }
.card-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.field-item { padding: 12px 16px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); cursor: pointer; transition: background 0.1s; position: relative; }
.field-item:hover { background: rgba(88,166,255,0.04); }
.field-item:hover::after { content: 'copier'; position: absolute; top: 8px; right: 10px; font-family: var(--font-mono); font-size: 9px; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; }
.field-item.wide { grid-column: 1 / -1; }
.field-label { font-size: 10px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }
.field-value { font-family: var(--font-mono); font-size: 13px; color: #e6edf3; word-break: break-all; line-height: 1.5; }
.field-value.empty    { color: var(--muted); }
.field-value.val-id   { color: var(--muted); font-size: 11px; }
.field-value.val-iban { color: var(--purple); letter-spacing: 0.03em; }
.field-value.val-pass { color: var(--red); }
.field-value.val-email{ color: var(--accent); }
.field-value.val-phone{ color: var(--green); }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(10px); background: #e6edf3; color: #0a0c10; font-family: var(--font-mono); font-size: 12px; font-weight: 500; padding: 8px 18px; border-radius: 20px; opacity: 0; pointer-events: none; transition: opacity 0.15s, transform 0.15s; z-index: 9999; white-space: nowrap; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.hidden { display: none !important; }

@media (max-width: 700px) {
    .search-zone, .no-credits-banner, .stats-bar, .loading, .error-box, .results { padding-left: 16px; padding-right: 16px; }
    .search-zone { margin-top: 32px; }
    .search-title { font-size: 22px; }
    .search-sub { margin-bottom: 20px; }
    .criteria-actions { flex-direction: column; align-items: stretch; }
    .criteria-hint { order: 2; }
    .btn-search { order: 1; width: 100%; padding: 12px 22px; }
    .stats-bar { flex-wrap: wrap; row-gap: 6px; }
    .card-fields { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    /* AST builder : les groupes imbriqués restent lisibles sur mobile. */
    .ast-group-header { gap: 6px; }
    .ast-group-label { display: none; }
    .ast-group-actions { margin-left: 0; flex-wrap: wrap; }
    .ast-group-body { padding: 8px 8px 10px 12px; }
    .ast-group.is-root > .ast-group-body { padding: 10px; }
}
@media (max-width: 900px) {
    /* Hamburger : la nav se replie sous un bouton. */
    .nav-toggle { display: flex; }
    .header-nav {
        position: absolute; top: 100%; left: 0; right: 0;
        flex-direction: column; gap: 0;
        background: var(--surface); border-bottom: 1px solid var(--border);
        padding: 6px; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
        max-height: 0; overflow: hidden; opacity: 0;
        transition: max-height 0.25s ease, opacity 0.2s, padding 0.2s;
        pointer-events: none;
    }
    .header.nav-open .header-nav {
        max-height: 80vh; opacity: 1; pointer-events: auto; padding: 6px;
    }
    .header-nav .nav-link { padding: 10px 12px; border-radius: 6px; }
    .header-nav .nav-link:hover { background: var(--surface2); }
    .header { position: sticky; }
    /* Sur mobile on masque les stats du header (visibles sur le dashboard). */
    .header-stats { display: none; }
}
@media (max-width: 560px) {
    .header { padding: 8px 14px; }
    .header-sep { display: none; }
    .user-chip { display: none; }
    .btn-logout { padding: 4px 9px; font-size: 11px; }
}

/* ==========================================================================
   Historique
   ========================================================================== */
.page { max-width: 1400px; margin: 0 auto; padding: 40px 20px; }
.page-header { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; }
.page-title { font-size: 22px; font-weight: 700; color: #e6edf3; letter-spacing: -0.02em; }
.page-count { font-family: var(--font-mono); font-size: 12px; color: var(--muted); background: var(--surface2); border: 1px solid var(--border); padding: 3px 10px; border-radius: 20px; }
.btn-danger {
    margin-left: auto; font-size: 12px; font-weight: 500;
    color: var(--red); background: transparent;
    border: 1px solid rgba(248,81,73,0.3); border-radius: 6px;
    padding: 6px 14px; cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.btn-danger:hover { background: rgba(248,81,73,0.08); border-color: var(--red); }

.hist-table { width: 100%; border-collapse: collapse; }
.hist-table thead th { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; text-align: left; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.hist-row { border-bottom: 1px solid var(--border); transition: background 0.1s; }
.hist-row:last-child { border-bottom: none; }
.hist-row:hover { background: rgba(88,166,255,0.03); }
.hist-row td { padding: 12px 16px; vertical-align: middle; }
.td-date { white-space: nowrap; }
.date-main { font-family: var(--font-mono); font-size: 12px; color: var(--text); }
.date-ago  { font-size: 11px; color: var(--muted); margin-top: 2px; }
.td-criteria { width: 100%; }
.criteria-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.cpill { font-family: var(--font-mono); font-size: 11px; color: var(--text); background: var(--surface2); border: 1px solid var(--border); padding: 3px 9px; border-radius: 5px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-count { white-space: nowrap; text-align: right; }
.count-badge { font-family: var(--font-mono); font-size: 11px; padding: 3px 9px; border-radius: 20px; border: 1px solid; }
.count-badge.found { color: var(--green); border-color: rgba(63,185,80,0.3); background: rgba(63,185,80,0.07); }
.count-badge.none  { color: var(--muted); border-color: var(--border); background: transparent; }
.td-actions { white-space: nowrap; text-align: right; }
.btn-rerun { font-size: 12px; font-weight: 500; color: var(--accent); background: transparent; border: 1px solid rgba(88,166,255,0.25); border-radius: 6px; padding: 5px 12px; text-decoration: none; transition: background 0.15s, border-color 0.15s; display: inline-block; }
.btn-rerun:hover { background: rgba(88,166,255,0.08); border-color: var(--accent); }
.btn-del { font-size: 12px; color: var(--muted); background: transparent; border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; cursor: pointer; margin-left: 6px; transition: color 0.15s, border-color 0.15s; }
.btn-del:hover { color: var(--red); border-color: rgba(248,81,73,0.4); }
.empty-state { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty-icon  { font-size: 36px; margin-bottom: 16px; opacity: 0.4; }
.empty-text  { font-size: 15px; margin-bottom: 8px; color: var(--text); }
.empty-sub   { font-size: 13px; }
.empty-state a { color: var(--accent); text-decoration: none; }
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 32px; }
.pag-btn { font-family: var(--font-mono); font-size: 12px; color: var(--muted); background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px; text-decoration: none; transition: color 0.15s, border-color 0.15s; }
.pag-btn:hover { color: var(--text); border-color: var(--border-h); }
.pag-btn.active { color: var(--accent); border-color: rgba(88,166,255,0.4); background: rgba(88,166,255,0.07); }
.pag-btn.disabled { opacity: 0.35; pointer-events: none; }
.hist-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }

/* ==========================================================================
   Docs
   ========================================================================== */
.page { padding: 36px 20px; }
.page-title { font-size: 26px; }
.page-sub { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.page-sub a { color: var(--accent); text-decoration: none; }
.page-sub a:hover { text-decoration: underline; }
.notice { display: flex; align-items: center; gap: 10px; background: rgba(255,166,87,0.07); border: 1px solid rgba(255,166,87,0.25); color: var(--orange); border-radius: 8px; padding: 10px 16px; font-size: 13px; margin: 20px 0 32px; }
.notice a { color: inherit; font-weight: 600; }
section { margin-bottom: 36px; }
h2 { font-size: 16px; font-weight: 700; color: #e6edf3; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
h3 { font-size: 13px; font-weight: 600; color: var(--text); margin: 18px 0 8px; }
p { font-size: 13px; line-height: 1.65; color: var(--text); margin-bottom: 10px; }
p.muted { color: var(--muted); }
code { font-family: var(--font-mono); font-size: 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; color: var(--purple); }
.endpoint { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.method { font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--green); background: rgba(63,185,80,0.1); border: 1px solid rgba(63,185,80,0.3); border-radius: 5px; padding: 3px 9px; }
.endpoint-path { font-family: var(--font-mono); font-size: 13px; color: var(--text); }
pre { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; overflow-x: auto; margin-bottom: 14px; }
pre code { background: none; border: none; padding: 0; color: var(--text); display: block; white-space: pre; }
.tok-key { color: var(--accent); }
.tok-str { color: var(--green); }
.tok-num { color: var(--orange); }
.tok-com { color: var(--muted); }
table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
thead th { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); }
tbody td { padding: 9px 12px; font-size: 12.5px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
td code { white-space: nowrap; }
.badge { font-family: var(--font-mono); font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 20px; border: 1px solid; }
.badge.req { color: var(--red); border-color: rgba(248,81,73,0.3); background: rgba(248,81,73,0.07); }
.badge.opt { color: var(--muted); border-color: var(--border); }

/* ==========================================================================
   Settings
   ========================================================================== */
.section { margin-bottom: 28px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 12px; }
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 20px; }
.alert.success { background: rgba(63,185,80,0.08); border: 1px solid rgba(63,185,80,0.25); color: var(--green); }
.alert.error   { background: rgba(248,81,73,0.08); border: 1px solid rgba(248,81,73,0.25); color: var(--red); }
.info-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--muted); }
.info-val { font-family: var(--font-mono); color: var(--text); }
.key-box { display: flex; align-items: stretch; gap: 8px; margin-bottom: 14px; }
.key-field { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; font-family: var(--font-mono); font-size: 13px; color: var(--text); overflow-x: auto; white-space: nowrap; display: flex; align-items: center; }
.key-field.empty { color: var(--muted); font-family: var(--font-ui); }
.btn { font-size: 12px; font-weight: 600; border: none; border-radius: 8px; padding: 10px 16px; cursor: pointer; white-space: nowrap; transition: opacity 0.15s, background 0.15s; }
.btn:hover { opacity: 0.88; }
.btn-accent { background: var(--accent); color: #0a0c10; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--border-h); opacity: 1; }
.btn-danger { background: transparent; border: 1px solid rgba(248,81,73,0.35); color: var(--red); }
.btn-danger:hover { background: rgba(248,81,73,0.08); opacity: 1; }
.key-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hint { font-size: 12px; color: var(--muted); margin-top: 12px; line-height: 1.5; }
.hint a { color: var(--accent); text-decoration: none; }
.hint a:hover { text-decoration: underline; }

/* ==========================================================================
   Admin
   ========================================================================== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 20px 22px; }
.stat-card-val { font-family: var(--font-mono); font-size: 28px; font-weight: 700; letter-spacing: -0.03em; color: #e6edf3; }
.stat-card-val.accent { color: var(--accent); }
.stat-card-val.green  { color: var(--green); }
.stat-card-val.orange { color: var(--orange); }
.stat-card-val.purple { color: var(--purple); }
.stat-card-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.thead th { white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.02); }
tbody td { padding: 11px 14px; font-size: 13px; vertical-align: middle; }
.td-mono { font-family: var(--font-mono); font-size: 12px; }
.td-muted { color: var(--muted); font-size: 12px; }
.cr-badge { font-family: var(--font-mono); font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; border: 1px solid; }
.cr-badge.ok   { color: var(--green);  border-color: rgba(63,185,80,0.3);  background: rgba(63,185,80,0.07); }
.cr-badge.low  { color: var(--orange); border-color: rgba(255,166,87,0.3); background: rgba(255,166,87,0.07); }
.cr-badge.none { color: var(--red);    border-color: rgba(248,81,73,0.3);  background: rgba(248,81,73,0.07); }
.admin-badge { font-family: var(--font-mono); font-size: 10px; color: var(--purple); background: rgba(210,168,255,0.1); border: 1px solid rgba(210,168,255,0.2); padding: 2px 7px; border-radius: 4px; }
.inline-form { display: flex; align-items: center; gap: 6px; }
.input-credits { width: 80px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; color: var(--text); font-family: var(--font-mono); font-size: 12px; outline: none; transition: border-color 0.15s; }
.input-credits:focus { border-color: var(--accent); }
.btn-sm { font-size: 11px; font-weight: 600; border: none; border-radius: 6px; padding: 5px 10px; cursor: pointer; white-space: nowrap; transition: opacity 0.15s; }
.btn-sm:hover { opacity: 0.85; }
.btn-set  { background: var(--accent);  color: #0a0c10; }
.btn-add  { background: var(--green);   color: #0a0c10; }
.btn-admin-toggle { background: rgba(210,168,255,0.15); color: var(--purple); border: 1px solid rgba(210,168,255,0.3); font-size: 11px; font-weight: 500; border-radius: 6px; padding: 5px 10px; cursor: pointer; }
.btn-admin-toggle:hover { background: rgba(210,168,255,0.25); }
.btn-delete { background: transparent; border: 1px solid rgba(248,81,73,0.3); color: var(--red); font-size: 11px; border-radius: 6px; padding: 5px 10px; cursor: pointer; }
.btn-delete:hover { background: rgba(248,81,73,0.08); }
.tx-pos { color: var(--green); font-weight: 600; }
.tx-neg { color: var(--red); }
.tabs { display: flex; gap: 2px; margin-bottom: 16px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 4px; width: fit-content; }
.tab { font-size: 12px; font-weight: 500; color: var(--muted); padding: 5px 14px; border-radius: 6px; cursor: pointer; border: none; background: transparent; transition: color 0.15s, background 0.15s; }
.tab.active { color: var(--text); background: var(--surface); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ==========================================================================
   Nouveaux composants (admin étendu, user-detail, settings forms, responsive)
   ========================================================================== */

/* Crédit illimité (badge) */
.cr-badge.unlim { color: var(--purple); border-color: rgba(210,168,255,0.3); background: rgba(210,168,255,0.08); font-weight: 600; }

/* Lignes désactivées dans la table admin */
tr.row-disabled { opacity: 0.55; }
tr.row-disabled:hover { background: rgba(248,81,73,0.04); }

/* Cellule utilisateur (username + email empilés) */
.user-cell { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.user-sub { font-size: 11px; width: 100%; }
.me-tag { font-size: 10px; color: var(--muted); }

/* Badges de statut */
.status-badge { font-family: var(--font-mono); font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 20px; border: 1px solid; white-space: nowrap; }
.status-badge.ok   { color: var(--green);  border-color: rgba(63,185,80,0.3);  background: rgba(63,185,80,0.07); }
.status-badge.warn { color: var(--orange); border-color: rgba(255,166,87,0.3); background: rgba(255,166,87,0.07); }
.status-badge.bad  { color: var(--red);    border-color: rgba(248,81,73,0.3);  background: rgba(248,81,73,0.07); }

/* Transaction montant zéro */
.tx-zero { color: var(--muted); }

/* En-tête de section admin (titre + recherche) */
.section-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.search-form { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.search-input {
    background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
    padding: 7px 12px; color: var(--text); font-family: var(--font-ui); font-size: 13px;
    outline: none; transition: border-color 0.15s; min-width: 220px;
}
.search-input:focus { border-color: var(--accent); }
.search-clear { color: var(--muted); text-decoration: none; font-size: 14px; }
.search-clear:hover { color: var(--red); }

/* Conteneur table scrollable horizontalement sur mobile */
.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 100%; }
.empty-row { text-align: center; color: var(--muted); padding: 40px 16px; }

/* Bouton "Gérer" */
.btn-manage {
    font-size: 12px; font-weight: 600; color: var(--accent);
    background: transparent; border: 1px solid rgba(88,166,255,0.25);
    border-radius: 6px; padding: 5px 12px; text-decoration: none; white-space: nowrap;
    display: inline-block; transition: background 0.15s, border-color 0.15s;
}
.btn-manage:hover { background: rgba(88,166,255,0.08); border-color: var(--accent); }

/* ── Page détail utilisateur (admin) ── */
.back-link { display: inline-block; font-size: 13px; color: var(--muted); text-decoration: none; margin-bottom: 20px; }
.back-link:hover { color: var(--accent); }
.ud-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.ud-title { font-size: 26px; font-weight: 700; color: #e6edf3; letter-spacing: -0.03em; }
.ud-sub { font-size: 13px; color: var(--muted); margin-bottom: 28px; font-family: var(--font-mono); }
.ud-actions-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.ud-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-right: 4px; align-self: center; }
.btn-toggle {
    font-size: 12px; font-weight: 600; border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 14px; cursor: pointer; white-space: nowrap;
    background: var(--surface2); color: var(--text);
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.btn-toggle:hover { border-color: var(--border-h); }
.btn-toggle.on  { color: var(--green); border-color: rgba(63,185,80,0.4); background: rgba(63,185,80,0.08); }
.btn-toggle.off { color: var(--red);   border-color: rgba(248,81,73,0.4); background: rgba(248,81,73,0.08); }
.ud-danger { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
.btn-danger-big {
    font-size: 13px; font-weight: 600; color: var(--red);
    background: transparent; border: 1px solid rgba(248,81,73,0.35);
    border-radius: 8px; padding: 10px 18px; cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.btn-danger-big:hover:not(:disabled) { background: rgba(248,81,73,0.08); border-color: var(--red); }
.btn-danger-big:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Settings : formulaires profil ── */
.settings-form { display: flex; flex-direction: column; gap: 12px; }
.settings-form .field { margin-bottom: 0; }
.settings-sep { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.notice { background: rgba(255,166,87,0.07); border: 1px solid rgba(255,166,87,0.25); color: var(--orange); border-radius: 8px; padding: 10px 16px; font-size: 13px; margin-bottom: 20px; }

/* ==========================================================================
   Responsive global des tables / pages sur petit écran
   ========================================================================== */
@media (max-width: 700px) {
    .page { padding: 28px 16px; }
    .page-title { font-size: 20px; }
    .section-head { flex-direction: column; align-items: stretch; }
    .search-form { margin-left: 0; }
    .search-input { min-width: 0; flex: 1; }
    .tabs { width: 100%; }
    .tab { flex: 1; text-align: center; }
    .ud-title { font-size: 22px; }
    .ud-actions-row .inline-form { flex-wrap: wrap; }
    .stat-card { padding: 16px 18px; }
    .stat-card-val { font-size: 24px; }
    .criteria-pills { gap: 4px; }
    .cpill { max-width: 180px; }
}
@media (max-width: 480px) {
    .header { padding: 8px 12px; gap: 8px; }
    .logo { font-size: 13px; }
    .nav-link { font-size: 13px; }
    .credits-chip { font-size: 10px; padding: 2px 7px; }
    .btn-logout { padding: 4px 8px; font-size: 11px; }
    .page { padding: 20px 12px; }
    .card { padding: 16px; }
    .ud-actions-row { gap: 8px; }
    .btn-toggle { padding: 7px 11px; font-size: 11px; }
}

/* ==========================================================================
   Turnstile, 2FA, admin étendu
   ========================================================================== */
.turnstile-wrap { display: flex; justify-content: center; margin-bottom: 16px; min-height: 65px; }
.twofa-toggle { text-align: center; margin-top: 16px; }
.twofa-toggle a { font-size: 12px; color: var(--accent); text-decoration: none; }
.twofa-toggle a:hover { text-decoration: underline; }

/* QR code container */
.qr-container { display: flex; justify-content: center; margin: 20px 0; }
.qr-container svg { border-radius: 8px; background: #e6edf3; padding: 8px; }
.totp-manual { margin: 12px 0 20px; }
.totp-manual summary { font-size: 12px; color: var(--muted); cursor: pointer; }
.totp-manual summary:hover { color: var(--text); }
.totp-secret { font-family: var(--font-mono); font-size: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; display: block; margin-top: 8px; word-break: break-all; color: var(--purple); }

/* Backup codes grid */
.backup-codes-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 16px 0; }
.backup-code { font-family: var(--font-mono); font-size: 14px; font-weight: 600; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 10px; color: var(--stamp); letter-spacing: 0.1em; }

/* Admin controls bar (registration toggle + create user button) */
.admin-controls-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.reg-toggle-wrap { display: flex; align-items: center; gap: 12px; }
.reg-label { font-size: 13px; color: var(--text); font-weight: 500; }

/* IP link (clickable IP addresses) */
.ip-link { font-family: var(--font-mono); font-size: 11px; color: var(--accent); text-decoration: none; }
.ip-link:hover { text-decoration: underline; }

/* User-Agent cell (truncated) */
.ua-cell { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Checkbox grid (create user form) */
.checkbox-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; padding: 8px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; transition: border-color 0.15s; }
.check-row:hover { border-color: var(--border-h); }
.check-row input { width: 16px; height: 16px; cursor: pointer; }

@media (max-width: 600px) {
    .checkbox-grid { grid-template-columns: 1fr; }
    .backup-codes-grid { grid-template-columns: 1fr; }
    .admin-controls-bar { flex-direction: column; align-items: stretch; }
    .ua-cell { max-width: 160px; }
}

/* Session actuelle (highlight) */
tr.row-current { background: rgba(88,166,255,0.04); }
tr.row-current:hover { background: rgba(88,166,255,0.07); }

/* Bouton delete petit (dans les tables) */
.btn-sm.btn-delete { background: transparent; border: 1px solid rgba(248,81,73,0.3); color: var(--red); }
