:root {
  --bg: #0b0d12;
  --bg-2: #11141d;
  --card: #151823;
  --card-2: #1b1f2c;
  --border: #232838;
  --border-2: #2d3346;
  --text: #e6e8ee;
  --muted: #8b93a7;
  --blurple: #5865f2;
  --blurple-d: #4752c4;
  --green: #3ba55d;
  --yellow: #faa61a;
  --orange: #e67e22;
  --red: #ed4245;
  --purple: #9b59b6;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "gg sans", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #1a1f33 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
a { color: var(--blurple); text-decoration: none; }
button { font-family: inherit; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 20px;
  padding: 40px 36px; text-align: center; max-width: 380px; width: 100%; box-shadow: var(--shadow);
}
.login-logo { font-size: 56px; line-height: 1; }
.login-card h1 { margin: 14px 0 2px; font-size: 30px; letter-spacing: .5px; }
.login-note { margin-top: 18px; font-size: 12px; color: var(--muted); }
.btn-discord {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 22px;
  background: var(--blurple); color: #fff; padding: 13px 22px; border-radius: 10px;
  font-weight: 600; transition: background .15s;
}
.btn-discord:hover { background: var(--blurple-d); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 22px; background: rgba(17,20,29,.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-logo { font-size: 22px; }
.brand-name { font-weight: 700; font-size: 18px; }
.brand-sub { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.guild-select {
  background: var(--card-2); color: var(--text); border: 1px solid var(--border-2);
  border-radius: 9px; padding: 8px 12px; font-size: 14px; cursor: pointer; max-width: 220px;
}
.user-chip { display: flex; align-items: center; gap: 8px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--card-2); object-fit: cover; }
.user-tag { font-size: 14px; font-weight: 600; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; padding: 14px 22px 0; flex-wrap: wrap; }
.tab {
  background: transparent; color: var(--muted); border: none; border-bottom: 2px solid transparent;
  padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer; border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--text); background: var(--card); }
.tab.active { color: #fff; border-bottom-color: var(--blurple); }

/* ---------- View ---------- */
.view { padding: 22px; max-width: 1180px; margin: 0 auto; }
.section-title { font-size: 16px; font-weight: 700; margin: 26px 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title:first-child { margin-top: 6px; }

/* ---------- Cards & grid ---------- */
.grid { display: grid; gap: 14px; }
.stats-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.cards-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.stat {
  background: linear-gradient(160deg, var(--card) 0%, var(--card-2) 100%);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
}
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.stat-value { font-size: 30px; font-weight: 800; margin-top: 6px; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Ticket card ---------- */
.ticket-card { display: flex; flex-direction: column; gap: 10px; cursor: pointer; transition: border-color .15s, transform .1s; }
.ticket-card:hover { border-color: var(--border-2); transform: translateY(-1px); }
.ticket-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ticket-id { font-family: ui-monospace, monospace; font-size: 13px; color: var(--blurple); font-weight: 700; }
.ticket-meta { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.ticket-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--border-2);
}
.badge.green { color: #fff; background: rgba(59,165,93,.18); border-color: rgba(59,165,93,.4); }
.badge.yellow { color: #ffd86b; background: rgba(250,166,26,.16); border-color: rgba(250,166,26,.4); }
.badge.red { color: #ff8e90; background: rgba(237,66,69,.16); border-color: rgba(237,66,69,.4); }
.badge.grey { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-2);
  background: var(--card-2); color: var(--text); padding: 9px 14px; border-radius: 9px;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--border); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-primary { background: var(--blurple); border-color: var(--blurple); color: #fff; }
.btn-primary:hover { background: var(--blurple-d); }
.btn-danger { background: rgba(237,66,69,.15); border-color: rgba(237,66,69,.45); color: #ff9b9d; }
.btn-danger:hover { background: rgba(237,66,69,.28); }
.btn-warn { background: rgba(250,166,26,.14); border-color: rgba(250,166,26,.4); color: #ffce80; }
.btn-warn:hover { background: rgba(250,166,26,.26); }
.btn-ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Forms ---------- */
input, select, textarea {
  width: 100%; background: var(--bg-2); color: var(--text); border: 1px solid var(--border-2);
  border-radius: 9px; padding: 10px 12px; font-size: 14px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blurple); }
textarea { resize: vertical; min-height: 64px; }
label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 5px; font-weight: 600; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 140px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.check input { width: auto; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.table tr:hover td { background: var(--card-2); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }

/* ---------- Member search ---------- */
.search-box { display: flex; gap: 10px; margin-bottom: 16px; }
.search-box input { flex: 1; }
.result-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border: 1px solid var(--border);
  border-radius: 11px; background: var(--card); cursor: pointer; margin-bottom: 8px;
}
.result-item:hover { border-color: var(--blurple); }
.result-item .avatar { width: 38px; height: 38px; }

/* ---------- Member file ---------- */
.member-header { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.member-header .avatar-lg { width: 76px; height: 76px; border-radius: 50%; }
.member-name { font-size: 22px; font-weight: 800; }
.member-id { font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.role-chip { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--border-2); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv .k { color: var(--muted); }

.two-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }

.sanction-row {
  display: flex; align-items: flex-start; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border);
}
.sanction-row:last-child { border-bottom: none; }
.sanction-emoji { font-size: 18px; }
.sanction-body { flex: 1; min-width: 0; }
.sanction-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.strike { text-decoration: line-through; opacity: .6; }

/* ---------- Ticket conversation ---------- */
.conv { display: flex; flex-direction: column; gap: 12px; max-height: 460px; overflow-y: auto; padding-right: 6px; }
.msg { display: flex; gap: 10px; }
.msg .avatar { width: 34px; height: 34px; flex-shrink: 0; }
.msg-body { min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: 700; font-size: 13px; }
.msg-time { font-size: 11px; color: var(--muted); }
.msg-content { font-size: 14px; white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.msg-att { font-size: 12px; }
.bot-tag { font-size: 9px; background: var(--blurple); color: #fff; padding: 1px 4px; border-radius: 4px; font-weight: 700; }

/* ---------- Mentions cliquables ---------- */
.mention {
  display: inline; cursor: pointer; color: #c5cbff; font-weight: 600;
  background: rgba(88,101,242,.16); border-radius: 4px; padding: 0 4px;
  transition: background .12s;
}
.mention:hover { background: rgba(88,101,242,.34); color: #fff; }

/* ---------- Admin / accès ---------- */
.access-block { margin-bottom: 14px; }
select[multiple] { min-height: 160px; padding: 6px; }
select[multiple] option { padding: 5px 8px; border-radius: 6px; }
.chips-edit { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; min-height: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  background: var(--card-2); border: 1px solid var(--border-2); border-radius: 999px; padding: 4px 6px 4px 10px;
}
.chip .x { cursor: pointer; background: var(--border); border-radius: 50%; width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px; line-height: 1; }
.chip .x:hover { background: var(--red); color: #fff; }
.add-row { display: flex; gap: 8px; }
.add-row input { flex: 1; }
.add-results { margin-top: 8px; }
.add-results .result-item { padding: 8px 12px; }
.save-bar { position: sticky; bottom: 0; padding: 14px 0 4px; display: flex; gap: 10px; align-items: center; background: linear-gradient(to top, var(--bg) 60%, transparent); }

/* ---------- Graphes (barres CSS) ---------- */
.chart { display: flex; align-items: flex-end; gap: 4px; height: 150px; padding-top: 6px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar { width: 70%; max-width: 26px; min-height: 0; background: linear-gradient(to top, var(--blurple-d), var(--blurple)); border-radius: 4px 4px 0 0; transition: height .2s; }
.bar-col:hover .bar { background: linear-gradient(to top, var(--blurple), #8b95ff); }
.bar-x { font-size: 9px; color: var(--muted); margin-top: 4px; white-space: nowrap; transform: rotate(-45deg); transform-origin: center; height: 14px; }

/* ---------- Flux de logs ---------- */
.logfeed { display: flex; flex-direction: column; }
.logrow { display: flex; align-items: flex-start; gap: 11px; padding: 10px 2px; border-bottom: 1px solid var(--border); }
.logrow:last-child { border-bottom: none; }
.logicon { font-size: 16px; line-height: 1.4; flex-shrink: 0; width: 22px; text-align: center; }
.logbody { flex: 1; min-width: 0; }
.logbody > div:first-child { font-size: 13px; }
.logtime { font-size: 11px; white-space: nowrap; flex-shrink: 0; padding-top: 2px; }
.logday {
  position: sticky; top: 0; background: var(--card); z-index: 1;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); padding: 10px 2px 6px; border-bottom: 1px solid var(--border-2);
}
.logrow { border-left: 3px solid transparent; padding-left: 9px; }
.logcat-sanction { border-left-color: var(--red); }
.logcat-ticket { border-left-color: var(--blurple); }
.logcat-request { border-left-color: var(--yellow); }
.logcat-note { border-left-color: var(--green); }
.logcat-panel { border-left-color: var(--border-2); }

.empty { color: var(--muted); text-align: center; padding: 30px; font-size: 14px; }
.loader { color: var(--muted); text-align: center; padding: 40px; }
.back-link { cursor: pointer; color: var(--muted); font-size: 13px; margin-bottom: 14px; display: inline-block; }
.back-link:hover { color: var(--text); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--card-2); border: 1px solid var(--border-2); color: var(--text);
  padding: 12px 20px; border-radius: 10px; box-shadow: var(--shadow); z-index: 100; font-size: 14px; font-weight: 600;
}
.toast.ok { border-color: rgba(59,165,93,.5); }
.toast.err { border-color: rgba(237,66,69,.5); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center;
  justify-content: center; z-index: 50; padding: 20px;
}
.modal { background: var(--card); border: 1px solid var(--border-2); border-radius: 16px; padding: 22px; max-width: 480px; width: 100%; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
