:root {
  --bg: #0f1013;
  --panel: #16171b;
  --card: #1e1f24;
  --card-2: #25262c;
  --border: #2c2e35;
  --text: #e3e5e8;
  --muted: #959ba5;
  --faint: #6b717c;
  --accent: #5b7cfa;
  --accent-2: #4866e8;
  --accent-soft: rgba(91, 124, 250, .14);
  --green: #3ba55d;
  --red: #ed4245;
  --yellow: #f0b232;
  --radius: 10px;
  --sidebar: 248px;
  --topbar: 60px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 Inter, system-ui, -apple-system, Segoe UI, sans-serif; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ── Top bar ── */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; background: rgba(15,16,19,.9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand svg { width: 26px; height: 26px; fill: var(--accent); stroke: none; }
.brand svg .tick { fill: none; stroke: #fff; stroke-width: 2.2; }
.userbox { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--card-2); object-fit: cover; }
.userbox .name { font-weight: 500; }
.userbox .logout { color: var(--muted); padding: 6px 10px; border-radius: 8px; }
.userbox .logout:hover { background: var(--card); color: var(--text); }

/* ── Buttons & controls ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 8px; border: 1px solid transparent; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; transition: background .15s, opacity .15s; white-space: nowrap; }
.btn:hover { background: var(--accent-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--card-2); border-color: var(--border); color: var(--text); }
.btn.secondary:hover { background: #2d2f36; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--card-2); color: var(--text); }
.btn.danger { background: var(--red); }
.btn.green { background: var(--green); }
.btn.sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn.lg { height: 48px; padding: 0 26px; font-size: 16px; }

.input, select.input, textarea.input { width: 100%; min-height: 38px; padding: 8px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; outline: none; transition: border-color .15s; }
.input:focus { border-color: var(--accent); }
.input.invalid { border-color: var(--red); }
textarea.input { min-height: 90px; resize: vertical; }
select.input { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23959ba5' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }

.switch { position: relative; display: inline-block; vertical-align: middle; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #3a3c44; border-radius: 99px; cursor: pointer; transition: background .2s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; min-height: 38px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 6px 0 10px; border-radius: 6px; background: var(--card-2); font-size: 13px; max-width: 100%; }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.chip .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { display: grid; place-items: center; width: 18px; height: 18px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); cursor: pointer; padding: 0; }
.chip button:hover { background: rgba(237,66,69,.2); color: var(--red); }
.chip button svg { width: 12px; height: 12px; }
.chips select, .chips input { flex: 1; min-width: 140px; height: 26px; border: 0; background: transparent; outline: none; padding: 0 6px; color: var(--muted); }
.chips select option { background: var(--card); color: var(--text); }

.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--card-2); color: var(--muted); white-space: nowrap; }
.badge.green { background: rgba(59,165,93,.16); color: #57d283; }
.badge.red { background: rgba(237,66,69,.16); color: #ff7a7c; }
.badge.yellow { background: rgba(240,178,50,.16); color: var(--yellow); }
.badge.blue { background: var(--accent-soft); color: #8ea5ff; }
.badge.purple { background: rgba(155,89,182,.18); color: #c48fe0; }
.badge.orange { background: rgba(230,126,34,.18); color: #f0a35e; }

/* ── Login ── */
.hero { min-height: calc(100vh - var(--topbar)); display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(900px 500px at 50% -10%, rgba(91,124,250,.18), transparent 70%); }
.hero-inner { text-align: center; max-width: 560px; }
.hero h1 { font-size: clamp(30px, 6vw, 46px); line-height: 1.1; margin: 0 0 14px; letter-spacing: -.03em; }
.hero p { color: var(--muted); font-size: 16px; margin: 0 0 28px; }
.hero .btn svg { width: 22px; height: 22px; fill: currentColor; stroke: none; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 40px; text-align: left; }
.feature { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.feature b { display: block; margin-bottom: 2px; }
.feature span { color: var(--muted); font-size: 13px; }

/* ── Server picker ── */
.container { max-width: 1100px; margin: 0 auto; padding: 32px 20px 80px; }
.page-title { font-size: 26px; font-weight: 700; margin: 0 0 6px; letter-spacing: -.02em; }
.page-sub { color: var(--muted); margin: 0 0 26px; }
.server-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.server-card { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px 16px 18px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; text-align: center; transition: transform .15s, border-color .15s; }
.server-card:hover { transform: translateY(-2px); border-color: #3a3d46; }
.server-card .gicon { width: 72px; height: 72px; }
.server-card .gname { font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-card .btn { width: 100%; }
.gicon { display: grid; place-items: center; border-radius: 50%; background: var(--card-2); color: var(--muted); font-weight: 600; object-fit: cover; overflow: hidden; }

/* ── Guild layout ── */
.layout { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: calc(100vh - var(--topbar)); }
.sidebar { position: sticky; top: var(--topbar); height: calc(100vh - var(--topbar)); overflow-y: auto; background: var(--panel); border-right: 1px solid var(--border); padding: 16px 12px 24px; }
.sidebar .ghead { display: flex; align-items: center; gap: 10px; padding: 8px; margin-bottom: 8px; border-radius: 10px; color: var(--text); }
.sidebar .ghead:hover { background: var(--card); }
.sidebar .ghead .gicon { width: 36px; height: 36px; font-size: 13px; }
.sidebar .ghead .gname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.sidebar .ghead svg { color: var(--faint); width: 16px; }
.nav-section { margin: 18px 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.nav a { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--card); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: #fff; }
.nav a.active svg { color: var(--accent); }
.nav a .state { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: #3a3c44; }
.nav a .state.on { background: var(--green); }
.mobile-nav { display: none; }

.content { padding: 30px 36px 120px; max-width: 980px; width: 100%; }
.module-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.module-head h2 { margin: 0 0 4px; font-size: 24px; letter-spacing: -.02em; }
.module-head p { margin: 0; color: var(--muted); }
.module-head .switch { margin-top: 6px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; }
.card h3 { margin: 0 0 4px; font-size: 15px; }
.card .desc { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.setting.stack { flex-direction: column; align-items: stretch; gap: 0; }
.setting .text { min-width: 0; flex: 1; }
.setting.inline .control { flex: 0 0 auto; }
.setting .text .desc { margin: 0; }
.setting .control { width: 100%; max-width: 100%; }
.setting.inline .control { width: auto; }
.hint { color: var(--faint); font-size: 12px; margin-top: 6px; }
.disabled-overlay { opacity: .45; pointer-events: none; }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); margin-bottom: 14px; font-size: 13px; border: 1px solid; }
.notice.warn { background: rgba(240,178,50,.08); border-color: rgba(240,178,50,.3); color: #f5d38a; }
.notice.info { background: var(--accent-soft); border-color: rgba(91,124,250,.35); color: #c3cffd; }
.notice svg { margin-top: 1px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat .k { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.quick a { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); }
.quick a:hover { border-color: #3a3d46; }
.quick a .ic { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); }
.quick a small { display: block; color: var(--muted); }

/* ── Commands ── */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .input { flex: 1; min-width: 180px; }
.toolbar select.input { flex: 0 0 auto; width: auto; min-width: 150px; }
.cmd-group h4 { margin: 22px 0 8px; font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }
.cmd { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; }
.cmd-row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; }
.cmd-row .info { flex: 1; min-width: 0; }
.cmd-row .title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; }
.cmd-row .title code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px; }
.cmd-row .title .alias { color: var(--faint); font-weight: 400; font-size: 12px; }
.cmd-row .d { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmd-row .gear { width: 34px; height: 34px; padding: 0; }
.cmd-row .gear.custom { color: var(--accent); }
.cmd-perms { border-top: 1px solid var(--border); padding: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cmd-perms label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.cmd-perms .hint { margin: 0 0 6px; }
.cmd-perms .actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; background: var(--panel); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td .sub { color: var(--faint); font-size: 12px; }
td.reason { max-width: 340px; word-break: break-word; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 12px; color: var(--muted); }
.progress { height: 8px; border-radius: 99px; background: var(--panel); overflow: hidden; margin: 10px 0; }
.progress > div { height: 100%; background: var(--green); transition: width .4s; }

/* ── Save bar & toasts ── */
.savebar { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 140%); z-index: 40; display: flex; align-items: center; gap: 16px; width: min(720px, calc(100% - 32px)); padding: 10px 10px 10px 18px; background: #0b0c0e; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.5); transition: transform .25s cubic-bezier(.2,.9,.3,1.2); }
.savebar.show { transform: translate(-50%, 0); }
.savebar .msg { flex: 1; font-weight: 500; }
.savebar.shake { animation: shake .4s; }
@keyframes shake { 20%,60% { transform: translate(calc(-50% - 6px), 0); } 40%,80% { transform: translate(calc(-50% + 6px), 0); } }
.toasts { position: fixed; top: 74px; right: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; min-width: 240px; max-width: 380px; padding: 12px 14px; border-radius: 10px; background: var(--card-2); border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: slidein .2s; }
.toast.ok svg { color: var(--green); }
.toast.err svg { color: var(--red); }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } }
.loading { display: grid; place-items: center; min-height: 60vh; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Mobile ── */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-nav { display: block; padding: 12px 16px 0; }
  .content { padding: 18px 16px 120px; }
  .cmd-perms { grid-template-columns: 1fr; }
  .setting:not(.inline) { flex-direction: column; align-items: stretch; }
  .userbox .name { display: none; }
  .module-head { align-items: center; }
}

/* ── Action cards, forms ── */
.action-card { border-color: #33363f; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.stack-fields { display: grid; gap: 12px; }
.row2 { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.input.color { width: 64px; padding: 4px; height: 38px; cursor: pointer; }
.inline-switch { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.btn.danger:hover { background: #d83c3e; }

/* ── Sticky editor + Discord-style preview ── */
.sticky-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.sticky-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.preview-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); margin-bottom: 6px; }
.dc-preview { background: #313338; border-radius: 8px; padding: 14px; color: #dbdee1; font-size: 15px; }
.dc-msg { display: flex; gap: 12px; }
.dc-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; flex-shrink: 0; color: #fff; }
.dc-body { min-width: 0; flex: 1; }
.dc-name { font-weight: 600; color: #f2f3f5; display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.dc-bot { background: #5865f2; color: #fff; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 3px; }
.dc-text { white-space: pre-wrap; word-break: break-word; line-height: 1.375; }
.dc-embed { display: flex; gap: 12px; margin-top: 6px; background: #2b2d31; border-left: 4px solid; border-radius: 4px; padding: 10px 14px 12px 12px; max-width: 432px; }
.dc-embed-main { min-width: 0; flex: 1; display: grid; gap: 6px; }
.dc-embed-title { font-weight: 700; color: #f2f3f5; }
.dc-embed-image { max-width: 100%; border-radius: 4px; margin-top: 4px; }
.dc-embed-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 4px; }
.dc-embed-footer { font-size: 12px; color: #b5bac1; }

/* ── Stats ── */
.stat-row { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--border); }
.placeholder-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.ph { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; color: var(--text); cursor: pointer; text-align: left; }
.ph:hover { border-color: var(--accent); }
.ph code { font-family: ui-monospace, Menlo, monospace; color: #8ea5ff; }
.ph span { font-size: 12px; color: var(--muted); }

/* ── Charts (dark only; series colours validated against the card surface) ── */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.chart-card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.chart-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart, .chart * { stroke: none; } /* the global icon style strokes every svg */
.chart .grid { stroke: #2c2e35; stroke-width: 1; }
.chart .axis { fill: var(--faint); font-size: 9px; font-family: Inter, system-ui, sans-serif; }
.chart .hit { fill: transparent; }
.chart .bar.s1 { fill: #3987e5; } .chart .bar.s2 { fill: #d95926; }
.chart .bar.hover { opacity: .75; }
.chart .line.s1 { fill: none; stroke: #3987e5; stroke-width: 2; stroke-linejoin: round; }
.chart .dot { fill: #3987e5; stroke: var(--panel); stroke-width: 2; opacity: 0; }
.chart .dot.hover { opacity: 1; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.legend > span, .chart-tip > div { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.sw.s1 { background: #3987e5; } .sw.s2 { background: #d95926; }
.chart-tip { display: none; position: absolute; top: 0; transform: translateX(-50%); background: #0b0c0e; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 12px; pointer-events: none; white-space: nowrap; z-index: 5; flex-direction: column; }
.chart-tip > div { display: flex; }

@media (max-width: 860px) {
  .sticky-grid { grid-template-columns: 1fr; }
}

/* ── Member roles ── */
.check { display: flex; align-items: center; gap: 10px; margin: 6px 0; font-size: 13px; }
.event-row { padding: 6px 0; border-top: 1px solid var(--border); font-size: 13px; }
.event-row:first-child { border-top: 0; }
