/* ---------- Variables ---------- */
:root, [data-theme="dark"] {
    --bg: #000; --card: #0a0a0a; --card2: #171717; --hover: #18181b;
    --text: #fafafa; --muted: #a1a1aa; --faint: #71717a;
    --border: #27272a; --solid: #fafafa; --solid-text: #09090b;
    --blue: #3b82f6; --green: #22c55e; --amber: #eab308; --red: #ef4444;
    --c1: #fafafa; --c2: #22c55e; --c3: #3b82f6; --c4: #a1a1aa; --c5: #ef4444;
}
[data-theme="light"] {
    --bg: #fafafa; --card: #ffffff; --card2: #f4f4f5; --hover: #f4f4f5;
    --text: #09090b; --muted: #52525b; --faint: #71717a;
    --border: #e4e4e7; --solid: #18181b; --solid-text: #fafafa;
    --blue: #2563eb; --green: #16a34a; --amber: #ca8a04; --red: #dc2626;
    --c1: #18181b; --c2: #16a34a; --c3: #2563eb; --c4: #71717a; --c5: #dc2626;
}

[data-theme="midnight"] {
    --bg: #050816; --card: #0b1020; --card2: #131a30; --hover: #111a33;
    --text: #e8ecff; --muted: #9aa4c7; --faint: #6b7599;
    --border: #1e2a4a; --solid: #93b4ff; --solid-text: #050816;
    --blue: #60a5fa; --green: #34d399; --amber: #fbbf24; --red: #f87171;
    --c1: #93b4ff; --c2: #34d399; --c3: #60a5fa; --c4: #6b7599; --c5: #f87171;
}
[data-theme="forest"] {
    --bg: #040a07; --card: #0a120d; --card2: #121d16; --hover: #101a13;
    --text: #ecf6ef; --muted: #94b19d; --faint: #688574;
    --border: #1f3326; --solid: #4ade80; --solid-text: #03160a;
    --blue: #38bdf8; --green: #4ade80; --amber: #facc15; --red: #f87171;
    --c1: #4ade80; --c2: #86efac; --c3: #38bdf8; --c4: #688574; --c5: #f87171;
}
[data-theme="sunset"] {
    --bg: #0b0605; --card: #130c0a; --card2: #1e1411; --hover: #1a100d;
    --text: #fbefe9; --muted: #c3a69b; --faint: #8e7167;
    --border: #3a2520; --solid: #fb923c; --solid-text: #1c0a00;
    --blue: #60a5fa; --green: #4ade80; --amber: #fbbf24; --red: #f87171;
    --c1: #fb923c; --c2: #4ade80; --c3: #60a5fa; --c4: #8e7167; --c5: #f87171;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    background: var(--bg); color: var(--text);
    font-family: "Inter", "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px; line-height: 1.5; min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.icon { flex-shrink: 0; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

/* ---------- Mise en page ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 255px; flex-shrink: 0; border-right: 1px solid var(--border);
    display: flex; flex-direction: column; padding: 16px 12px;
    position: sticky; top: 0; height: 100vh;
}
.main { flex: 1; min-width: 0; padding: 28px 32px 64px; max-width: 1280px; }
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }

.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 16px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.logo {
    width: 40px; height: 40px; border-radius: 8px; background: var(--card2); border: 1px solid var(--border);
    display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.logo.lg { width: 64px; height: 64px; border-radius: 12px; font-size: 24px; }
.brand-name { font-weight: 600; font-size: 16px; line-height: 1.2; }
.brand-sub { font-size: 12px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 12px; color: var(--faint); padding: 16px 12px 6px; }
.nav a {
    display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px;
    color: var(--muted); border: 1px solid transparent; transition: background .12s, color .12s;
}
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a.active { background: var(--card2); border-color: var(--border); color: var(--text); font-weight: 500; }

.side-foot { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); }
.user-card img { width: 32px; height: 32px; border-radius: 50%; }
.user-card span { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-row { display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.side-row .select { width: 100%; }
.logout { display: flex; align-items: center; gap: 10px; padding: 8px 12px; color: var(--muted); border-radius: 8px; }
.logout:hover { background: var(--hover); color: var(--text); }

/* ---------- En-tête de page ---------- */
.page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 200px; }
.page-title { margin: 0; font-size: 28px; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
.page-sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.server-icon { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; flex-shrink: 0; }
.server-icon.placeholder { background: var(--card2); border: 1px solid var(--border); display: grid; place-items: center; font-weight: 600; font-size: 18px; }
.section-title { font-size: 16px; font-weight: 600; margin: 32px 0 12px; }

/* ---------- Cartes ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.card h3 { margin: 0 0 16px; font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card h3 .icon { color: var(--muted); }
.grid { display: grid; gap: 16px; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.charts { grid-template-columns: 2fr 1fr; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: start; }

.stat .ico { width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; margin-bottom: 16px;
    background: color-mix(in srgb, var(--tone) 12%, transparent); color: var(--tone);
    border: 1px solid color-mix(in srgb, var(--tone) 22%, transparent); }
.stat .value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat .label { color: var(--muted); margin-top: 4px; }
.stat .sub { margin-top: 10px; }

.kv { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: none; padding-bottom: 0; }
.kv:first-child { padding-top: 0; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { text-align: right; overflow-wrap: anywhere; }

.chart-box { position: relative; height: 260px; }
.empty-mini { padding: 24px 0; text-align: center; color: var(--faint); }
.note { margin-top: 24px; color: var(--faint); font-size: 12px; }

/* ---------- Pastilles ---------- */
.badge, .chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 500; border: 1px solid var(--border); background: var(--card2); color: var(--muted);
}
.badge.ok { color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); border-color: color-mix(in srgb, var(--green) 25%, transparent); }
.badge.info { color: var(--blue); background: color-mix(in srgb, var(--blue) 12%, transparent); border-color: color-mix(in srgb, var(--blue) 25%, transparent); }
.badge.err { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); border-color: color-mix(in srgb, var(--red) 25%, transparent); }
.up { color: var(--green); }
.down { color: var(--red); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
button.chip { cursor: pointer; font-family: ui-monospace, Menlo, Consolas, monospace; transition: background .12s; }
button.chip:hover { background: var(--hover); color: var(--text); }

/* ---------- Boutons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
    border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--text);
    font-weight: 500; cursor: pointer; transition: background .12s;
}
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--solid); color: var(--solid-text); border-color: var(--solid); }
.btn-primary:hover { background: var(--solid); opacity: .88; }
.btn-lg { height: 48px; width: 100%; }
.btn-block { width: 100%; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }

/* ---------- Formulaires ---------- */
.field { margin-bottom: 20px; }
.field.row { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.field-label { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.field.row .field-label { margin-bottom: 2px; }
.field-label .icon { color: var(--muted); }
.hint { color: var(--faint); font-size: 12px; margin-top: 6px; }
.input, .select {
    width: 100%; height: 44px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--card); color: var(--text);
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.select { height: 36px; width: auto; font-size: 13px; cursor: pointer; }
.input:hover, .select:hover { border-color: var(--faint); }
.input:focus-visible, .select:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.input-icon .input { padding-left: 38px; }

.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.slider { position: absolute; inset: 0; background: var(--card2); border: 1px solid var(--border); border-radius: 999px; transition: background .15s; }
.slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + .slider { background: var(--solid); border-color: var(--solid); }
.switch input:checked + .slider::before { transform: translateX(20px); background: var(--solid-text); }
.switch input:focus-visible + .slider { outline: 2px solid var(--text); outline-offset: 2px; }

.cat-row { padding: 14px 0; border-bottom: 1px solid var(--border); margin: 0; }
.cat-row:last-child { border-bottom: none; }
.cat-title { font-weight: 500; }
.cat-row .hint { margin-top: 2px; }

/* ---------- Messages ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid var(--border); }
.alert .icon { margin-top: 2px; }
.alert.success { color: var(--green); background: color-mix(in srgb, var(--green) 10%, transparent); border-color: color-mix(in srgb, var(--green) 25%, transparent); }
.alert.error { color: var(--red); background: color-mix(in srgb, var(--red) 10%, transparent); border-color: color-mix(in srgb, var(--red) 25%, transparent); }
.alert.warn { color: var(--amber); background: color-mix(in srgb, var(--amber) 10%, transparent); border-color: color-mix(in srgb, var(--amber) 25%, transparent); }
.alert span { color: var(--text); }

/* ---------- Liste de serveurs ---------- */
.rows .row-item { display: flex; align-items: center; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.rows .row-item:last-child { border-bottom: none; }
.rows { padding: 0; overflow: hidden; }
.row-item .name { font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .server-icon { width: 40px; height: 40px; border-radius: 8px; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }

/* ---------- Connexion / erreur ---------- */
.auth-card { width: 100%; max-width: 420px; padding: 32px; text-align: center; }
.auth-card .logo { margin: 0 auto 16px; }
.auth-card h1 { margin: 0 0 6px; font-size: 22px; font-weight: 600; }
.auth-card p { margin: 0 0 24px; color: var(--muted); }
.auth-foot { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--faint); font-size: 12px; }
.auth-foot a { color: var(--muted); }
.auth-foot a:hover { color: var(--text); }
.err-code { font-size: 48px; font-weight: 700; line-height: 1; margin-bottom: 12px; }

/* ---------- Bienvenue ---------- */
.card-preview { width: 100%; border-radius: 8px; border: 1px solid var(--border); display: block; background: var(--card2); }
.msg-preview { margin: 12px 0; padding: 10px 12px; border-radius: 8px; background: var(--card2); border: 1px solid var(--border); white-space: pre-wrap; overflow-wrap: anywhere; }
.log-list { list-style: none; margin: 0 0 16px; padding: 0; }
.log-list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); color: var(--muted); }
.log-list li:last-child { border-bottom: none; }
.preview-col .card > .small { margin: 0 0 16px; color: var(--faint); }
.preview-col .card form .btn { margin-top: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .cols-4 { grid-template-columns: repeat(2, 1fr); } .charts { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); padding: 12px 16px; }
    .brand { border-bottom: none; margin-bottom: 8px; padding-bottom: 4px; }
    .nav { flex-direction: row; overflow-x: auto; flex: none; gap: 4px; padding-bottom: 8px; }
    .nav a { white-space: nowrap; }
    .nav-label { display: none; }
    .side-foot { flex-direction: row; align-items: center; border-top: none; padding-top: 0; }
    .side-row { flex-direction: row; align-items: center; }
    .user-card { flex: 1; min-width: 0; }
    .logout span { display: none; }
    .main { padding: 20px 16px 48px; }
    .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 640px) { .cols-4, .cols-2 { grid-template-columns: 1fr; } .page-title { font-size: 24px; } }

/* ---------- Vitrine ---------- */
.site-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 32px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand-inline { display: flex; align-items: center; gap: 12px; }
.site-nav { display: flex; align-items: center; gap: 20px; color: var(--muted); flex-wrap: wrap; }
.site-nav a:not(.btn):hover { color: var(--text); }
.site { max-width: 880px; margin: 0 auto; padding: 72px 24px 48px; }
.site-hero { margin-bottom: 72px; }
.site-hero h1 { margin: 0 0 16px; font-size: 40px; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; max-width: 640px; }
.site-hero p { margin: 0 0 24px; color: var(--muted); font-size: 16px; max-width: 560px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-meta { display: flex; align-items: center; gap: 10px; margin-top: 24px; color: var(--muted); font-size: 13px; }
.site .card p { margin: 0; }
.site section + section { margin-top: 56px; }
.site-foot { display: flex; justify-content: space-between; max-width: 880px; margin: 0 auto; padding: 24px; border-top: 1px solid var(--border); color: var(--faint); font-size: 12px; }
.site-foot a:hover { color: var(--text); }

/* ---------- Éditeur de message ---------- */
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.preview-sticky { position: sticky; top: 16px; }
.ed { display: flex; flex-direction: column; gap: 12px; }
.ed-field { margin-bottom: 0; flex: 1; min-width: 0; }
.ed-label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.ed-row { display: flex; gap: 12px; flex-wrap: wrap; }
.ed-row .half { flex: 1 1 180px; }
.ed-inline { align-items: center; }
.ed-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; }
.ed-color { width: 40px; height: 32px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); cursor: pointer; }
.ed .input { height: 38px; font-size: 13px; }
.ed textarea.input { height: auto; }
.ed-embed, .ed-tools { border: 1px solid var(--border); border-radius: 8px; background: var(--card); }
.ed-embed > summary, .ed-tools > summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; cursor: pointer; font-weight: 500; list-style: none; }
.ed-embed > summary::-webkit-details-marker, .ed-tools > summary::-webkit-details-marker { display: none; }
.ed-embed[open] > summary, .ed-tools[open] > summary { border-bottom: 1px solid var(--border); }
.ed-sum-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-body { display: flex; flex-direction: column; gap: 12px; padding: 12px; }
.ed-actions { display: inline-flex; gap: 4px; flex-shrink: 0; }
.ed-btn { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; }
.ed-btn:hover:not([disabled]) { background: var(--hover); color: var(--text); }
.ed-btn[disabled] { opacity: .35; cursor: not-allowed; }
.ed-sub { display: flex; flex-direction: column; gap: 8px; }
.ed-fieldbox { border: 1px solid var(--border); border-radius: 8px; padding: 10px; background: var(--card2); display: flex; flex-direction: column; gap: 8px; }
.ed-fieldhead { display: flex; justify-content: space-between; align-items: center; }
.ed-fieldhead .ed-label { margin: 0; }

/* ---------- Aperçu Discord ---------- */
.dc { display: flex; gap: 12px; padding: 12px; border-radius: 8px; background: var(--card2); border: 1px solid var(--border); }
.dc-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--border) center/cover; flex-shrink: 0; display: grid; place-items: center; font-weight: 600; }
.dc-body { min-width: 0; flex: 1; }
.dc-head { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.dc-name { font-weight: 600; }
.dc-tag { background: var(--solid); color: var(--solid-text); font-size: 10px; font-weight: 700; padding: 0 4px; border-radius: 4px; line-height: 16px; }
.dc-content, .dc-desc, .dc-fval { overflow-wrap: anywhere; line-height: 1.45; }
.dc-content code, .dc-desc code, .dc-fval code { background: var(--bg); padding: 0 4px; border-radius: 4px; font-size: 12px; }
.dc-body a { color: var(--blue); }
.dc-embed { display: flex; gap: 12px; margin-top: 6px; padding: 10px 12px; border-left: 4px solid var(--border); border-radius: 4px; background: var(--card); max-width: 480px; }
.dc-embed-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.dc-author, .dc-footer { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 500; }
.dc-footer { color: var(--muted); font-weight: 400; }
.dc-author img, .dc-footer img { width: 20px; height: 20px; border-radius: 50%; }
.dc-title { font-weight: 600; }
.dc-fields { display: flex; flex-wrap: wrap; gap: 8px; }
.dc-field { flex: 1 1 100%; min-width: 0; }
.dc-field.inline { flex: 1 1 calc(33% - 8px); }
.dc-fname { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.dc-fval { font-size: 13px; }
.dc-img { max-width: 100%; border-radius: 4px; }
.dc-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.dc-li { display: block; padding-left: 4px; }
@media (max-width: 640px) { .site { padding-top: 40px; } .site-hero h1 { font-size: 30px; } .site-head { padding: 12px 16px; } }

/* Listes d'éléments (sondages, giveaways, niveaux, modération) */
.item { margin-bottom: 12px; }
.item-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; }
.item-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 12px; }
.bar-row { display: flex; justify-content: space-between; font-size: 13px; margin-top: 8px; }
.bar { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; margin-top: 4px; }
.bar span { display: block; height: 100%; background: var(--solid); }
.grid-2, .grid-3 { display: grid; gap: 8px; margin-bottom: 8px; }
.grid-2 { grid-template-columns: 110px 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
textarea.input { resize: vertical; min-height: 90px; font-family: inherit; }

/* Sondages, giveaways, niveaux, modération */
.item { margin-bottom: 16px; }
.item-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.item-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.bar-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-top: 8px; }
.bar { height: 6px; border-radius: 4px; background: var(--border); overflow: hidden; margin-top: 4px; }
.bar > div { height: 100%; background: var(--solid); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 110px 1fr; gap: 8px; }
.reward-row { margin-bottom: 8px; }
.tier-head { font-size: 12px; margin-bottom: 4px; }
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.rank-list li:last-child { border-bottom: 0; }
.rank-pos { width: 24px; height: 24px; border-radius: 6px; background: var(--border); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.case-list li { align-items: flex-start; }
@media (max-width: 640px) { .grid3 { grid-template-columns: 1fr; } }
