:root {
    --bg: #0a0a0a; --s1: #151515; --s2: #1f1f1f; --line: rgba(255,255,255,.12); --text: #f3f2ee; --muted: #a3a29c;
    --zest: #ff6b1a; --leaf: #22b86b; --leaf-2: #63d696; --danger: #ff5a46; --warn: #ffb020;
    color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--leaf-2); }
h1 { font-size: 1.9rem; margin: 0 0 1.5rem; letter-spacing: -.02em; }
h2 { font-size: 1.2rem; margin: 2rem 0 1rem; }
.card h2 { margin-top: 0; }
code { background: var(--s2); padding: .1rem .35rem; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--leaf-2); outline-offset: 2px; }

.admin { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 1.5rem 1rem; border-right: 1px solid var(--line); background: #000; }
.sidebar-logo { display: block; margin: 0 .5rem 2rem; }
.sidebar nav { display: grid; gap: .15rem; }
.sidebar nav a { display: flex; justify-content: space-between; align-items: center; padding: .6rem .75rem; border-radius: 8px; color: var(--muted); text-decoration: none; }
.sidebar nav a:hover { background: var(--s1); color: var(--text); }
.sidebar nav a.is-active { background: var(--zest); color: #1a0a00; font-weight: 600; }
.badge { background: var(--leaf); color: #021a0d; border-radius: 99px; padding: 0 .5rem; font-size: .8rem; font-weight: 700; }
.sidebar-foot { margin-top: auto; display: grid; gap: .5rem; padding: 0 .75rem; font-size: .9rem; }
.main { padding: 2rem clamp(1rem, 3vw, 3rem) 4rem; max-width: 1400px; min-width: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: .65rem 1.1rem; border-radius: 99px; border: 1px solid transparent; background: var(--zest); color: #1a0a00; font: inherit; font-weight: 650; text-decoration: none; cursor: pointer; }
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn--danger { background: transparent; color: var(--danger); border-color: rgba(255,90,70,.4); }
.btn--sm { padding: .4rem .8rem; font-size: .88rem; }
.linklike { background: none; border: 0; padding: 0; color: var(--leaf-2); font: inherit; cursor: pointer; text-decoration: underline; }
.linklike:disabled { opacity: .4; cursor: not-allowed; }
.linklike.danger { color: var(--danger); }

.card { background: var(--s1); border: 1px solid var(--line); border-radius: 16px; padding: 1.5rem; margin-bottom: 1.5rem; }
.form { display: grid; gap: 1rem; }
.form label { display: grid; gap: .35rem; font-weight: 600; font-size: .92rem; }
.form input:not([type=checkbox]):not([type=radio]), .form select, .form textarea {
    width: 100%; padding: .65rem .8rem; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-weight: 400;
}
.form textarea { resize: vertical; }
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--zest); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace !important; font-size: .88rem !important; }
.check { display: flex !important; grid-template-columns: none; gap: .55rem; align-items: center; font-weight: 500 !important; }
.check input { accent-color: var(--zest); width: 17px; height: 17px; }
.check--inline { align-self: end; padding-bottom: .6rem; }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-4 { grid-template-columns: repeat(4, 1fr); }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.actions form { display: flex; gap: .6rem; }
.sticky-actions { position: sticky; bottom: 0; padding: 1rem 0; background: linear-gradient(transparent, var(--bg) 40%); }
.toolbar { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; margin: 0 0 1.5rem; }
.hint, .muted { color: var(--muted); font-size: .9rem; font-weight: 400; }
.empty { color: var(--muted); padding: 2rem; border: 1px dashed var(--line); border-radius: 12px; text-align: center; }
.counter { color: var(--muted); font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.2rem; display: grid; gap: 1rem; }
legend { padding: 0 .4rem; font-weight: 700; }

.alert { padding: .8rem 1rem; border-radius: 10px; margin: 0 0 1rem; border: 1px solid; }
.alert--ok { background: rgba(34,184,107,.1); border-color: rgba(34,184,107,.45); color: var(--leaf-2); }
.alert--error { background: rgba(255,90,70,.1); border-color: rgba(255,90,70,.45); color: #ffb4a8; }
.alert--warn { background: rgba(255,176,32,.1); border-color: rgba(255,176,32,.45); color: #ffd58a; }

.table { width: 100%; border-collapse: collapse; background: var(--s1); border-radius: 12px; overflow: hidden; margin-bottom: 1rem; }
.table th, .table td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: .85rem; }
.table tr.is-unread td { font-weight: 650; }
.row-actions { display: flex; gap: 1rem; align-items: center; white-space: nowrap; }
.row-actions form { margin: 0; }
.tag { display: inline-block; padding: .1rem .55rem; border-radius: 99px; font-size: .8rem; background: var(--s2); color: var(--muted); }
.tag--ok { background: rgba(34,184,107,.18); color: var(--leaf-2); }
.tag--warn { background: rgba(255,176,32,.15); color: #ffd58a; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stat { background: var(--s1); border: 1px solid var(--line); border-radius: 14px; padding: 1.2rem; display: grid; gap: .2rem; color: var(--muted); }
.stat-n { font-size: 2.2rem; font-weight: 750; color: var(--text); line-height: 1; }
.progress { height: 8px; background: var(--s2); border-radius: 99px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--leaf); transition: width 1s; }

.matrix-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--s1); }
.matrix { border-collapse: collapse; min-width: 100%; }
.matrix th, .matrix td { padding: .35rem; border-bottom: 1px solid var(--line); text-align: center; }
.matrix thead th { height: 130px; vertical-align: bottom; font-weight: 500; font-size: .82rem; color: var(--muted); }
.matrix thead th span { display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
.matrix tbody th { text-align: left; font-weight: 500; white-space: nowrap; padding: .35rem .9rem; position: sticky; left: 0; background: var(--s1); }
.matrix-cat td { text-align: left; padding: .9rem .9rem .4rem; color: var(--zest); font-weight: 700; }
.cell { display: inline-block; width: 22px; height: 22px; border-radius: 6px; vertical-align: middle; transition: transform .15s; }
a.cell:hover { transform: scale(1.25); }
.cell--published { background: var(--leaf); }
.cell--draft { background: var(--zest); }
.cell--none { background: var(--s2); border: 1px solid var(--line); }
.cell--error { background: var(--danger); }
.cell--busy { background: var(--warn); animation: pulse .8s infinite alternate; }
@keyframes pulse { to { opacity: .35; } }
.legend { display: flex; gap: .5rem; align-items: center; color: var(--muted); }
.legend .cell { width: 14px; height: 14px; margin-left: .8rem; }
.gen-status { color: var(--muted); }

.providers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.provider { display: grid; gap: .8rem; align-content: start; padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.provider-foot { display: flex; justify-content: space-between; align-items: center; }
.test-result { margin: 0; font-size: .88rem; }
.test-result.is-ok { color: var(--leaf-2); }
.test-result.is-error { color: #ffb4a8; }

.leads { display: grid; gap: .6rem; }
.lead { padding: 0; margin: 0; }
.lead summary { display: grid; grid-template-columns: 1.3fr 1.3fr .7fr; gap: 1rem; padding: 1rem 1.3rem; cursor: pointer; list-style: none; }
.lead summary::-webkit-details-marker { display: none; }
.lead.is-unread { border-color: rgba(34,184,107,.6); }
.lead.is-unread .lead-name::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--leaf); margin-right: .5rem; }
.lead-name { font-weight: 650; }
.lead > :not(summary) { margin: 0 1.3rem 1rem; }
.lead-meta { display: grid; grid-template-columns: 140px 1fr; gap: .3rem 1rem; }
.lead-meta dt { color: var(--muted); }
.lead-meta dd { margin: 0; }
.lead-msg { background: var(--bg); padding: 1rem; border-radius: 10px; }

.auth { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; background: radial-gradient(circle at 70% 20%, rgba(34,184,107,.15), transparent 50%), #000; }
.auth-card { width: min(420px, 100%); background: var(--s1); border: 1px solid var(--line); border-radius: 20px; padding: 2.2rem; }
.auth-card--wide { width: min(680px, 100%); }
.auth-logo { display: block; margin-bottom: 1.5rem; }
.auth h1 { font-size: 1.5rem; }

@media (max-width: 1000px) {
    .admin { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .sidebar nav { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
    .providers, .stats, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
    .providers, .stats, .grid-2, .grid-3, .grid-4, .lead summary { grid-template-columns: 1fr; }
}

/* ---------- E-mails et demandes ---------- */
h3 { font-size: 1rem; margin: 1.2rem 0 .5rem; }
.seg { display: flex; flex-wrap: wrap; gap: .5rem; }
.seg label { display: flex !important; align-items: center; gap: .5rem; padding: .6rem 1rem; border: 1px solid var(--line); border-radius: 99px; cursor: pointer; font-weight: 500 !important; }
.seg label:has(input:checked) { border-color: var(--zest); background: rgba(255,107,26,.1); }
.chip { padding: .3rem .75rem; margin: 0 .2rem .3rem 0; border-radius: 99px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: .85rem; cursor: pointer; }
.chip:hover { border-color: var(--zest); }
[data-smtp-fields] { display: grid; gap: 1rem; }
[data-smtp-fields][hidden] { display: none; }
.test-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.test-row input { flex: 1; min-width: 220px; }
.preview { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; font: inherit; margin: 0; }
.tag--error { background: rgba(255,90,70,.18); color: #ffb4a8; }
.tabs { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.tabs a { padding: .55rem .9rem; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a span { font-size: .8rem; background: var(--s2); border-radius: 99px; padding: 0 .45rem; margin-left: .2rem; }
.tabs a.is-active { color: var(--text); border-color: var(--zest); }
.toolbar input[type=search], .toolbar select, .test-row input { padding: .55rem .8rem; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
.toolbar input[type=search] { min-width: 260px; }
.prio { display: inline-block; padding: .1rem .55rem; border-radius: 99px; font-size: .8rem; font-weight: 650; }
.prio--haute { background: rgba(255,107,26,.2); color: #ffb07a; }
.prio--moyenne { background: rgba(255,176,32,.14); color: #ffd58a; }
.prio--basse { background: var(--s2); color: var(--muted); }
.status { font-size: .85rem; }
.status--new { color: var(--leaf-2); font-weight: 650; }
.status--won { color: var(--leaf-2); }
.status--lost, .status--spam { color: var(--muted); }
.lead-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1.5rem; align-items: start; }
.lead-grid .card .lead-meta, .lead-grid .card .lead-msg { margin: 0 0 1rem; }
.mail-item { border-top: 1px solid var(--line); padding: .7rem 0; }
.mail-item summary { cursor: pointer; }
.mail-item .lead-msg { margin-top: .7rem; }
.ai-list { margin: 0; padding-left: 1.2rem; color: var(--muted); }
.ai-list li { margin-bottom: .3rem; }
.danger-zone { text-align: right; }
@media (max-width: 1100px) { .lead-grid { grid-template-columns: 1fr; } }
