:root {
  --bg: #0f1115;
  --bg2: #161920;
  --card: #1c2029;
  --card2: #232835;
  --border: #2c3242;
  --text: #e8eaf0;
  --muted: #8f97a8;
  --gold: #f5c542;
  --gold2: #d9a91c;
  --green: #3fc97b;
  --red: #ef5a5a;
  --orange: #f0a038;
  --blue: #5b8cff;
  --discord: #5865f2;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, sans-serif;
}
a { color: var(--gold); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
h1, h2, h3 { margin: 0 0 8px; }
h3 { font-size: 15px; }

/* ---------- Boutons et champs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid var(--border); background: var(--card2); color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600;
  text-decoration: none; transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { border-color: var(--gold2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--gold); color: #1b1600; border-color: var(--gold); }
.btn.primary:hover { background: var(--gold2); }
.btn.success { background: #1f3b2b; border-color: var(--green); color: var(--green); }
.btn.danger { background: #3b1f22; border-color: var(--red); color: var(--red); }
.btn.blue { background: #1f2a45; border-color: var(--blue); color: #a9c1ff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.discord { background: var(--discord); border-color: var(--discord); color: #fff; padding: 12px 22px; font-size: 15px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

input, textarea, select {
  width: 100%; background: var(--bg2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font: inherit;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold); }
label { display: block; font-weight: 600; margin: 10px 0 4px; }
label .muted { font-weight: 400; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 8px 0; }
.check input { width: auto; }

/* ---------- Pages simples (connexion, erreurs) ---------- */
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card.narrow { max-width: 420px; width: 100%; text-align: center; }
.login-card { padding: 36px 28px; }
.logo-big {
  width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 20px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--gold), #ff8a3d); color: #1b1600; font-size: 36px; font-weight: 800;
}

/* ---------- Mise en page ---------- */
#app { display: flex; min-height: 100vh; }
#sidebar {
  width: 250px; flex-shrink: 0; background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px; border-bottom: 1px solid var(--border); }
.brand img { width: 42px; height: 42px; border-radius: 50%; background: var(--card2); }
.brand-name { font-weight: 700; }
.status-pill { font-size: 12px; color: var(--muted); }
.status-pill.on { color: var(--green); }
.status-pill.off { color: var(--red); }
#nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
#nav button {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; background: none; border: 0;
  color: var(--muted); padding: 9px 12px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 500;
}
#nav button:hover { background: var(--card); color: var(--text); }
#nav button.active { background: var(--card2); color: var(--gold); }
#nav .nav-icon { width: 20px; text-align: center; }
.me { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.me img { width: 30px; height: 30px; border-radius: 50%; background: var(--card2); }
.me span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { flex: 1; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 16px 24px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); z-index: 5; }
.topbar h2 { flex: 1; margin: 0; font-size: 20px; }
#menu-toggle { display: none; }
#page { padding: 24px; max-width: 1200px; }
.banner { background: #3b1f22; color: #ffb4b4; padding: 10px 24px; border-bottom: 1px solid var(--red); }

/* ---------- Composants ---------- */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .value { font-size: 24px; font-weight: 700; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.section-title { margin: 26px 0 12px; font-size: 16px; color: var(--gold); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--card2); color: var(--muted); }
.badge.on { background: #1f3b2b; color: var(--green); }
.badge.off { background: #3b1f22; color: var(--red); }
.badge.warn { background: #3d2e17; color: var(--orange); }
.badge.gold { background: #3b3317; color: var(--gold); }
.error-box { background: #2a1a1d; border: 1px solid #5c2a30; color: #ffb4b4; border-radius: 8px; padding: 8px 10px; font-family: monospace; font-size: 12px; word-break: break-word; margin-top: 8px; }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tabs button { background: var(--card); border: 1px solid var(--border); color: var(--muted); padding: 6px 12px; border-radius: 99px; cursor: pointer; font: inherit; }
.tabs button.active { background: var(--gold); color: #1b1600; border-color: var(--gold); font-weight: 600; }
.setting { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting:last-child { border-bottom: 0; }
.setting .hint { color: var(--muted); font-size: 12px; }
.search { margin-bottom: 14px; }
.emoji { width: 1.25em; height: 1.25em; vertical-align: -0.25em; object-fit: contain; }
.mention { background: #2a2f5a; color: #c9cdfb; padding: 0 3px; border-radius: 4px; }
.preview { background: var(--bg2); border-left: 4px solid var(--gold); border-radius: 6px; padding: 10px 12px; white-space: pre-wrap; word-break: break-word; }
.code { font-family: monospace; background: var(--bg2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--card2); border: 1px solid var(--border); border-radius: 99px; padding: 3px 4px 3px 10px; font-size: 12px; }
.chip button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0 4px; }
.chip button:hover { color: var(--red); }
.picker { position: relative; }
.picker-results { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin-top: 4px; background: var(--card2); border: 1px solid var(--border); border-radius: 8px; max-height: 240px; overflow-y: auto; }
.picker-results button { display: flex; width: 100%; gap: 8px; align-items: center; padding: 7px 10px; background: none; border: 0; color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.picker-results button:hover { background: var(--card); }
.picker-results img { width: 22px; height: 22px; border-radius: 50%; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.off { background: var(--red); }
.dot.warn { background: var(--orange); }

/* ---------- Notifications et fenêtres ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--card2); border: 1px solid var(--border); border-left: 4px solid var(--muted); border-radius: 8px; padding: 10px 14px; box-shadow: 0 8px 24px #0008; white-space: pre-wrap; word-break: break-word; }
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
.toast.wait { border-left-color: var(--gold); }
.modal-back { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow-y: auto; }
.modal .btn-row { margin-top: 16px; justify-content: flex-end; }

/* ---------- Téléphone ---------- */
@media (max-width: 820px) {
  #sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  #sidebar.open { transform: none; box-shadow: 0 0 40px #000c; }
  #menu-toggle { display: inline-flex; }
  #page { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .setting { grid-template-columns: 1fr; }
  .grid.wide { grid-template-columns: 1fr; }
}
