:root {
  --bg: #07070c;
  --bg2: #0d0d16;
  --panel: rgba(22, 20, 36, 0.72);
  --panel-solid: #151325;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #ecebf5;
  --muted: #9a97b3;
  --faint: #6b6884;
  --accent: #a855f7;
  --accent2: #ec4899;
  --grad: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 16px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(168, 85, 247, 0.16), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(236, 72, 153, 0.10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}
a { color: #c4a4ff; text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }

.boot { display: grid; place-items: center; height: 100vh; }
.spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.08); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(440px, 100%); padding: 40px 36px; text-align: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: 24px;
  backdrop-filter: blur(18px); box-shadow: 0 30px 80px rgba(0,0,0,.5);
  animation: fadeUp .4s ease;
}
.logo-badge {
  width: 72px; height: 72px; margin: 0 auto 18px; border-radius: 22px; display: grid; place-items: center;
  background: var(--grad); box-shadow: 0 12px 40px rgba(168,85,247,.45); font-size: 34px;
}
.login-card h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: -.02em; }
.login-card p { color: var(--muted); margin: 0 0 26px; line-height: 1.5; }
.discord-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  padding: 13px 18px; border-radius: 12px; border: 0; cursor: pointer; font-weight: 600; font-size: 15px;
  background: #5865f2; color: #fff; transition: transform .15s, box-shadow .15s;
}
.discord-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 30px rgba(88,101,242,.45); text-decoration: none; }
.login-foot { margin-top: 22px; font-size: 12px; color: var(--faint); display: flex; gap: 6px; justify-content: center; align-items: center; }
.alert { padding: 11px 14px; border-radius: 12px; margin-bottom: 18px; font-size: 13px; text-align: left; }
.alert.bad { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.3); color: #fecaca; }
.alert.warn { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); color: #fde68a; }
.alert.info { background: rgba(168,85,247,.1); border: 1px solid rgba(168,85,247,.3); color: #e9d5ff; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 20px 14px;
  background: rgba(10, 9, 18, .75); border-right: 1px solid var(--border); backdrop-filter: blur(14px);
  display: flex; flex-direction: column; gap: 6px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; }
.brand img, .brand .logo-mini { width: 38px; height: 38px; border-radius: 12px; }
.brand .logo-mini { background: var(--grad); display: grid; place-items: center; font-size: 18px; }
.brand b { font-size: 16px; display: block; }
.brand small { color: var(--faint); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }

.guild-switch {
  display: flex; align-items: center; gap: 10px; padding: 10px; margin-bottom: 10px;
  border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,.02);
}
.guild-switch img, .guild-switch .gicon { width: 32px; height: 32px; border-radius: 10px; flex: none; }
.guild-switch .gicon { background: #2a2740; display: grid; place-items: center; font-weight: 700; }
.guild-switch select { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; font-weight: 600; cursor: pointer; }
.guild-switch select option { background: var(--panel-solid); }

.nav-section { color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px;
  color: var(--muted); cursor: pointer; transition: background .15s, color .15s; font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,.04); color: var(--text); text-decoration: none; }
.nav-item.active { background: linear-gradient(90deg, rgba(168,85,247,.22), rgba(236,72,153,.08)); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.nav-item .ico { width: 20px; text-align: center; }
.nav-item .lock { margin-left: auto; font-size: 11px; opacity: .7; }

.user-box { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid var(--border); }
.user-box img { width: 34px; height: 34px; border-radius: 50%; }
.user-box .meta { flex: 1; min-width: 0; }
.user-box .meta b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-box .meta small { color: var(--faint); }

.main { padding: 32px 40px 120px; max-width: 1240px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; animation: fadeUp .3s ease; }
.page-head h2 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.page-head p { margin: 6px 0 0; color: var(--muted); }

/* ---------- Cards ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; backdrop-filter: blur(12px); animation: fadeUp .35s ease;
}
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card .sub { color: var(--muted); margin: 0 0 16px; font-size: 13px; line-height: 1.5; }
.card + .card { margin-top: 16px; }
.grid > .card + .card, .grid > .card { margin-top: 0; }
.grid > div > .card + .card { margin-top: 16px; }
.grid + .card, .card + .grid { margin-top: 16px; }
.stat { position: relative; overflow: hidden; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.stat .value { font-size: 32px; font-weight: 700; margin-top: 8px; letter-spacing: -.02em; }
.stat .hint { color: var(--faint); font-size: 12px; margin-top: 4px; }
.stat::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%;
  background: var(--grad); opacity: .12; filter: blur(4px);
}

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: 13px; }
.field .help { color: var(--faint); font-size: 12px; }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border-radius: 10px; outline: none;
  background: rgba(0,0,0,.28); border: 1px solid var(--border-strong); transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(168,85,247,.2); }
select.input option { background: var(--panel-solid); }
textarea.input { min-height: 90px; resize: vertical; }
.input.small { width: 90px; padding: 7px 10px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.color-input { width: 46px; height: 38px; padding: 2px; border-radius: 10px; border: 1px solid var(--border-strong); background: transparent; cursor: pointer; }

.toggle { display: inline-block; vertical-align: middle; position: relative; width: 42px; height: 24px; flex: none; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle span { position: absolute; inset: 0; background: #3b3757; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); border-radius: 99px; transition: background .2s; }
.toggle span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle input:checked + span { background: var(--grad); }
.toggle input:checked + span::before { transform: translateX(18px); }
.toggle input:disabled + span { opacity: .5; cursor: not-allowed; }
.toggle-line { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.toggle-line:last-child { border-bottom: 0; }
.toggle-line .t b { display: block; }
.toggle-line .t small { color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border-strong); background: rgba(255,255,255,.04); font-weight: 600; transition: all .15s;
}
.btn:hover { background: rgba(255,255,255,.08); }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 8px 24px rgba(168,85,247,.3); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { background: rgba(239,68,68,.14); border-color: rgba(239,68,68,.4); color: #fecaca; }
.btn.small { padding: 6px 11px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 99px;
  background: rgba(255,255,255,.06); border: 1px solid var(--border); font-size: 12px; font-weight: 600;
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.chip button { border: 0; background: rgba(255,255,255,.08); width: 18px; height: 18px; border-radius: 50%; cursor: pointer; line-height: 1; padding: 0; }
.chip button:hover { background: var(--bad); }
.chip.static { padding-right: 10px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.badge.ok { background: rgba(34,197,94,.14); color: #86efac; }
.badge.bad { background: rgba(239,68,68,.14); color: #fca5a5; }
.badge.warn { background: rgba(245,158,11,.14); color: #fcd34d; }
.badge.info { background: rgba(168,85,247,.16); color: #d8b4fe; }
.badge.muted { background: rgba(255,255,255,.06); color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.disabled td { opacity: .45; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell img { width: 28px; height: 28px; border-radius: 50%; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; color: var(--muted); }
.empty { text-align: center; color: var(--faint); padding: 34px 10px; }
.msg-box { min-width: 220px; white-space: pre-wrap; word-break: break-word; background: rgba(0,0,0,.25); border: 1px solid var(--border); padding: 10px 12px; border-radius: 10px; max-width: 520px; }

.savebar {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 140%); z-index: 50;
  display: flex; align-items: center; gap: 16px; padding: 12px 14px 12px 20px; border-radius: 14px;
  background: #1a1730; border: 1px solid var(--border-strong); box-shadow: 0 20px 60px rgba(0,0,0,.6);
  transition: transform .25s cubic-bezier(.2,.9,.3,1.2);
}
.savebar.show { transform: translate(-50%, 0); }

#toasts { position: fixed; top: 18px; right: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast {
  min-width: 260px; max-width: 380px; padding: 12px 16px; border-radius: 12px; background: #1a1730;
  border: 1px solid var(--border-strong); box-shadow: 0 16px 40px rgba(0,0,0,.5); animation: fadeUp .25s ease;
  border-left: 3px solid var(--accent);
}
.toast.ok { border-left-color: var(--ok); }
.toast.bad { border-left-color: var(--bad); }

.owner-banner {
  display: flex; gap: 14px; align-items: center; padding: 14px 18px; border-radius: 14px; margin-bottom: 18px;
  background: linear-gradient(90deg, rgba(168,85,247,.18), rgba(236,72,153,.1)); border: 1px solid rgba(168,85,247,.35);
}
.owner-banner .big { font-size: 24px; }
.owner-banner small { color: var(--muted); display: block; }

.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.perm-opt { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--border); cursor: pointer; }
.perm-opt:hover { background: rgba(255,255,255,.03); }
.perm-opt input { accent-color: var(--accent); }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab { padding: 7px 14px; border-radius: 99px; border: 1px solid var(--border); cursor: pointer; color: var(--muted); font-weight: 600; font-size: 12px; background: transparent; }
.tab.active { background: rgba(168,85,247,.2); color: #fff; border-color: rgba(168,85,247,.5); }

.mobile-top { display: none; }

@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 60; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: none; }
  .mobile-top { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: rgba(7,7,12,.85); backdrop-filter: blur(10px); z-index: 40; }
  .main { padding: 22px 16px 120px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}

.row.nowrap { flex-wrap: nowrap; }
.row.nowrap .input.small { width: 72px; }
td select.input { min-width: 170px; }

/* ---------- Pré-visualização estilo Discord ---------- */
.dc-msg { display: flex; gap: 14px; padding: 18px; border-radius: var(--radius); background: #313338; border: 1px solid rgba(0,0,0,.3); color: #dbdee1; font-size: 15px; }
.dc-avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.dc-content { min-width: 0; flex: 1; }
.dc-author { font-weight: 600; color: #f2f3f5; display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.dc-app { background: #5865f2; color: #fff; font-size: 10px; padding: 1px 5px; border-radius: 4px; font-weight: 700; }
.dc-time { color: #949ba4; font-size: 12px; font-weight: 400; }
.dc-mention { display: inline-block; background: rgba(88,101,242,.3); color: #c9cdfb; border-radius: 4px; padding: 0 3px; margin-bottom: 6px; font-weight: 500; }
.dc-container { background: #2b2d31; border: 1px solid #1e1f22; border-left: 4px solid #a855f7; border-radius: 8px; padding: 14px 16px; max-width: 520px; display: flex; flex-direction: column; gap: 10px; }
.dc-title { font-size: 20px; font-weight: 700; color: #f2f3f5; margin-bottom: 4px; }
.dc-body { white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
.dc-section { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.dc-thumb { width: 80px; height: 80px; border-radius: 8px; object-fit: cover; flex: none; }
.dc-image { width: 100%; border-radius: 8px; display: block; }
.dc-sep { height: 1px; background: #3f4147; }
.dc-footer { font-size: 12px; color: #949ba4; }
.dc-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.dc-btn { background: #4e5058; color: #fff; padding: 6px 14px; border-radius: 6px; font-size: 14px; font-weight: 500; }
.dc-select { display: flex; justify-content: space-between; background: #1e1f22; border: 1px solid #1e1f22; border-radius: 6px; padding: 10px 12px; color: #949ba4; }
.dc-options { margin-top: 8px; background: #2b2d31; border-radius: 8px; padding: 6px; border: 1px solid #1e1f22; max-width: 520px; margin-left: 54px; }
.dc-option { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 6px; color: #dbdee1; }
.dc-option:hover { background: #35373c; }
.dc-option small { display: block; color: #949ba4; }
.sticky { position: sticky; top: 20px; }
.type-card { border-left: 3px solid var(--accent); }
.type-emoji { font-size: 22px; }
.btn-row { margin-bottom: 8px; }
.dlg { width: min(900px, 94vw); max-height: 86vh; background: var(--panel-solid); color: var(--text); border: 1px solid var(--border-strong); border-radius: 16px; padding: 20px; }
.dlg::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(3px); }
.transcript { white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: rgba(0,0,0,.3); padding: 14px; border-radius: 10px; max-height: 66vh; overflow: auto; margin: 0; }

/* ---------- Ícones ---------- */
.icon { flex: none; display: inline-block; vertical-align: -0.15em; }
.with-icon { display: inline-flex; align-items: center; gap: 7px; }
h3.with-icon { display: flex; }
.nav-item .ico { display: inline-flex; align-items: center; justify-content: center; }
.nav-item .lock { display: inline-flex; }
.nav-item.active .ico { color: #e9d5ff; }
.logo-badge, .brand .logo-mini { color: #fff; }
.login-foot { gap: 7px; }
.alert { display: flex; gap: 10px; align-items: flex-start; }
.alert .icon { margin-top: 1px; }
.toast { display: flex; gap: 10px; align-items: center; }
.toast.ok .icon { color: var(--ok); }
.toast.bad .icon { color: var(--bad); }
.btn.icon-only { padding: 7px; }
.owner-banner .big { display: inline-flex; color: #e9d5ff; }
.empty-icon { display: inline-flex; padding: 12px; border-radius: 50%; background: rgba(168,85,247,.12); color: #c4a4ff; margin-bottom: 10px; }
.chip .icon { opacity: .8; }
.badge .icon { margin-right: 1px; }
.help.with-icon { gap: 4px; }
.type-emoji { display: inline-flex; color: #c4a4ff; }
.rank { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 8px; border-radius: 99px; font-weight: 700; font-size: 13px; background: rgba(255,255,255,.06); color: var(--muted); }
.rank-1 { background: linear-gradient(135deg, #fde68a, #f59e0b); color: #3b2300; }
.rank-2 { background: linear-gradient(135deg, #f1f5f9, #94a3b8); color: #1e293b; }
.rank-3 { background: linear-gradient(135deg, #fdba74, #c2410c); color: #2a1200; }
.dc-btn { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Seletor com busca ---------- */
.card { position: relative; }
.card.combo-open { z-index: 40; }
.combo { position: relative; width: 100%; }
.combo-trigger { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; cursor: pointer; min-height: 40px; }
.combo-trigger:disabled { opacity: .55; cursor: not-allowed; }
.combo-label { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; white-space: nowrap; }
.combo-label > span:not(.dot) { overflow: hidden; text-overflow: ellipsis; }
.combo-label small, .combo-opt small { color: var(--faint); font-size: 11px; margin-left: 2px; white-space: nowrap; }
.combo-placeholder { color: var(--muted); }
.combo-chevron { opacity: .6; transition: transform .15s; }
.combo.open .combo-chevron { transform: rotate(180deg); }
.combo.open .combo-trigger { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(168,85,247,.2); }
.combo-pop {
  display: none; position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 50;
  background: #17152a; border: 1px solid var(--border-strong); border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,.6); overflow: hidden; animation: fadeUp .15s ease;
}
.combo.open .combo-pop { display: block; }
.combo-search-wrap { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); color: var(--muted); }
.combo-search { border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 4px 0; }
.combo-list { max-height: 260px; overflow-y: auto; padding: 6px; }
.combo-opt { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--text); }
.combo-opt .icon { color: var(--muted); }
.combo-opt.active { background: rgba(168,85,247,.18); }
.combo-opt.selected .combo-name { font-weight: 700; }
.combo-opt.empty-opt { color: var(--muted); font-style: italic; }
.combo-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-check { margin-left: auto; color: var(--accent) !important; }
.combo-none { padding: 16px; text-align: center; color: var(--faint); }
.combo .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.cmd-list { display: flex; flex-direction: column; gap: 8px; }
.cmd { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.cmd code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: rgba(168,85,247,.14); color: #e9d5ff; padding: 3px 8px; border-radius: 6px; }
.cmd span { color: var(--muted); font-size: 13px; }
