:root {
  --bg:         #1e1f2e;
  --bg-nav:     #16171f;
  --bg-sidebar: #16171f;
  --bg-card:    #252637;
  --bg-input:   #1a1b28;
  --bg-modal:   #1e1f2e;
  --border:     #2e2f45;
  --accent:     #5865f2;
  --accent-h:   #4752c4;
  --green:      #57f287;
  --red:        #ed4245;
  --yellow:     #fee75c;
  --text:       #dcddea;
  --muted:      #7d7e9a;
  --dim:        #4a4b65;
  --sidebar-w:  240px;
  --topbar-h:   48px;
  --radius:     8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; min-height: 100vh; }
a { color: inherit; text-decoration: none; }

/* ── TOPBAR ── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  height: var(--topbar-h);
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem;
}
.topbar-brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1rem; }
.brand-icon { font-size: 1.2rem; }
.topbar-right { display: flex; align-items: center; gap: .75rem; font-size: .82rem; }
.topbar-avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.topbar-username { color: var(--text); font-weight: 500; }
.topbar-logout { color: var(--muted); padding: .2rem .5rem; border-radius: 4px; }
.topbar-logout:hover { color: var(--text); background: var(--border); }

/* ── LAYOUT ── */
.app-layout {
  display: flex;
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: fixed;
  top: var(--topbar-h);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: .75rem 0;
  z-index: 100;
}

.server-selector {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .75rem;
  margin: 0 .5rem .25rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .1s;
  font-weight: 600; font-size: .88rem;
}
.server-selector:hover { background: var(--border); }
.server-sel-icon {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.server-sel-placeholder {
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem;
}
.server-sel-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-sel-arrow { color: var(--muted); font-size: .7rem; }

.sidebar-divider {
  height: 1px; background: var(--border);
  margin: .4rem .75rem;
}
.sidebar-group-label {
  font-size: .68rem; font-weight: 700;
  letter-spacing: .08em; color: var(--muted);
  padding: .5rem .75rem .2rem;
  text-transform: uppercase;
}
.sidebar-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .45rem .75rem;
  margin: 0 .4rem;
  border-radius: 6px;
  color: var(--muted); font-size: .88rem;
  transition: color .1s, background .1s;
  cursor: pointer;
}
.sidebar-item:hover { color: var(--text); background: rgba(255,255,255,.05); }
.sidebar-item.active { color: var(--text); background: rgba(88,101,242,.2); }
.si-icon { font-size: .9rem; width: 18px; text-align: center; flex-shrink: 0; }

/* ── CONTENT AREA ── */
.content-area {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 1.5rem 2rem;
  min-width: 0;
  max-width: 900px;
}

.page-wrap { max-width: 760px; }

/* ── SERVER HEADER (overview) ── */
.server-header {
  display: flex; align-items: center; gap: 1rem; margin-bottom: 2rem;
}
.server-header-icon {
  width: 56px; height: 56px; border-radius: 50%; object-fit: cover;
}
.server-header-placeholder {
  background: var(--dim); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem; letter-spacing: .05em;
}
.server-header-name { font-size: 1.4rem; font-weight: 700; }

.section-title {
  font-size: .75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); margin-bottom: .5rem;
}
.section-divider { height: 1px; background: var(--border); margin-bottom: 1.5rem; }

/* ── STATS ROW ── */
.stats-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.stat-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.25rem; min-width: 120px; text-align: center;
}
.stat-num { font-size: 1.3rem; font-weight: 700; }
.stat-lbl { font-size: .75rem; color: var(--muted); margin-top: .25rem; }

/* ── CONFIG CARD ── */
.config-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.config-card-title {
  font-size: .78rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; margin-bottom: .5rem;
}
.config-card-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  margin-bottom: 1rem;
}
.config-desc { font-size: .82rem; color: var(--muted); margin-bottom: .75rem; line-height: 1.5; }

/* ── INPUTS ── */
.config-input, .config-textarea {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text);
  padding: .5rem .75rem; font-size: .88rem; width: 100%;
  font-family: inherit; transition: border-color .15s;
}
.config-input:focus, .config-textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(88,101,242,.2);
}
.config-textarea { resize: vertical; min-height: 100px; }
.field-label { font-size: .75rem; font-weight: 600; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: .35rem; }
.field-hint { font-size: .72rem; color: var(--dim); margin-top: .3rem; }
.char-count { font-size: .72rem; color: var(--dim); text-align: right; margin-top: .2rem; }

/* ── COOLDOWN ROW ── */
.cooldown-row { display: flex; gap: .75rem; align-items: center; }
.cd-unit { display: flex; align-items: center; gap: .3rem; }
.cd-input {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text);
  padding: .5rem .6rem; font-size: .88rem; width: 70px; text-align: center;
  font-family: inherit;
}
.cd-input:focus { outline: none; border-color: var(--accent); }
.cd-label { color: var(--muted); font-weight: 600; font-size: .82rem; }

/* ── RANGE ROW ── */
.range-row { display: flex; align-items: center; gap: .75rem; }
.range-input { width: 160px; }
.range-sep { color: var(--muted); font-size: .82rem; flex-shrink: 0; }

/* ── PERCENT INPUT ── */
.pct-input-row { display: flex; align-items: center; gap: .5rem; }
.pct-input { width: 140px; }
.pct-suffix { color: var(--muted); font-weight: 600; }

/* ── RADIO OPTIONS ── */
.radio-row { display: flex; gap: 1rem; }
.radio-option {
  flex: 1; display: flex; align-items: center; gap: .6rem;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 6px; padding: .6rem 1rem; cursor: pointer;
  font-size: .88rem; transition: border-color .15s, background .15s;
}
.radio-option input { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }
.radio-option.selected { border-color: var(--accent); background: rgba(88,101,242,.1); }

/* ── TOGGLE ── */
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; cursor: pointer; flex-shrink: 0; }
.toggle-input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--dim); border-radius: 24px; transition: .2s; }
.toggle-slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: white; border-radius: 50%; transition: .2s; }
.toggle-input:checked + .toggle-slider { background: var(--accent); }
.toggle-input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── TWO COL ── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: .75rem; }

/* ── REPLY SECTION ── */
.reply-tabs { display: flex; border-bottom: 1px solid var(--border); margin: 1rem 0 .75rem; }
.reply-tab {
  padding: .5rem 1rem; font-size: .78rem; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color .15s, border-color .15s;
}
.reply-tab.active { color: var(--text); border-color: var(--accent); }
.reply-tab:hover { color: var(--text); }

.reply-toolbar { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.search-input {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); padding: .4rem .75rem;
  font-size: .82rem; flex: 1;
}
.search-input:focus { outline: none; border-color: var(--accent); }

.replies-list { display: flex; flex-direction: column; gap: .5rem; }
.reply-item {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 6px; padding: .75rem 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.reply-text { font-size: .88rem; flex: 1; word-break: break-word; }
.reply-actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.reply-type-badge { font-size: .7rem; font-weight: 600; padding: .1rem .5rem; border-radius: 20px; }
.reply-type-success { background: rgba(87,242,135,.15); color: var(--green); }
.reply-type-fail    { background: rgba(237,66,69,.15);  color: var(--red); }

/* ── STORE GRID ── */
.store-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .5rem; }
.store-toolbar { display: flex; gap: .5rem; align-items: center; }
.btn-options {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 6px; color: var(--muted); padding: .35rem .75rem;
  font-size: .78rem; cursor: pointer;
}
.store-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1rem; margin-top: 1rem;
}
.store-create-card {
  background: var(--bg-input); border: 2px dashed var(--border);
  border-radius: var(--radius); padding: 1.5rem 1rem;
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  cursor: pointer; transition: border-color .15s, background .15s; text-align: center;
}
.store-create-card:hover { border-color: var(--accent); background: rgba(88,101,242,.05); }
.store-create-icon { font-size: 2rem; color: var(--muted); font-weight: 300; }
.store-create-label { font-size: .72rem; font-weight: 700; letter-spacing: .06em; color: var(--muted); }
.store-item-card {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: .4rem;
  position: relative; transition: border-color .15s;
}
.store-item-card:hover { border-color: var(--accent); }
.store-item-icon { font-size: 1.8rem; }
.store-item-name { font-size: .82rem; font-weight: 600; word-break: break-word; }
.store-item-price { font-size: .78rem; color: var(--muted); }
.store-item-actions { display: flex; gap: .3rem; margin-top: .25rem; }
.btn-item-edit {
  background: rgba(88,101,242,.15); color: var(--accent); border: none;
  border-radius: 4px; padding: .2rem .4rem; cursor: pointer; font-size: .75rem;
}

/* ── DISCORD PREVIEW ── */
.preview-label { font-size: .7rem; font-weight: 600; letter-spacing: .07em; color: var(--muted); text-transform: uppercase; margin: 1rem 0 .5rem; }
.discord-preview {
  background: #36393f; border-radius: 8px; padding: 1rem; max-width: 420px;
}
.dp-bot-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.dp-bot-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.dp-bot-name { font-weight: 600; font-size: .92rem; color: #fff; }
.dp-embed {
  display: flex; background: #2f3136; border-radius: 4px; overflow: hidden;
}
.dp-embed-bar { width: 4px; background: var(--accent); flex-shrink: 0; }
.dp-embed-body { padding: .75rem; flex: 1; }
.dp-user-row { display: flex; align-items: center; gap: .4rem; margin-bottom: .6rem; }
.dp-user-avatar {
  width: 20px; height: 20px; border-radius: 50%; background: var(--dim);
  display: flex; align-items: center; justify-content: center; font-size: .65rem;
}
.dp-user-name { font-size: .82rem; font-weight: 600; color: #fff; }
.dp-balances { display: flex; gap: 1.5rem; }
.dp-bal-label { font-size: .72rem; color: #b9bbbe; margin-bottom: .15rem; }
.dp-bal-value { font-size: .88rem; color: #fff; }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; }
.audit-table, .data-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.audit-table th, .data-table th {
  text-align: left; padding: .45rem .6rem;
  color: var(--muted); font-size: .72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; border-bottom: 1px solid var(--border);
}
.audit-table td, .data-table td {
  padding: .5rem .6rem; border-bottom: 1px solid rgba(46,47,69,.5); vertical-align: middle;
}
.audit-table tr:last-child td, .data-table tr:last-child td { border-bottom: none; }
.audit-table tbody tr:hover, .data-table tbody tr:hover { background: rgba(88,101,242,.04); }

/* ── MISC ── */
.muted { color: var(--muted); }
.amt-in  { color: var(--green); font-weight: 600; }
.amt-out { color: var(--red);   font-weight: 600; }
.tag {
  display: inline-block; font-size: .7rem; font-weight: 600; padding: .1rem .45rem;
  border-radius: 20px; background: rgba(88,101,242,.15); color: var(--accent);
}
.uid {
  font-family: 'Consolas', monospace; font-size: .78rem;
  color: var(--muted); background: var(--bg); padding: .1rem .3rem; border-radius: 3px;
}
.cmd-tag {
  font-family: 'Consolas', monospace; font-size: .82rem;
  color: #8ab4f8; background: rgba(138,180,248,.1); padding: .05rem .35rem; border-radius: 3px;
}
.inline-code {
  font-family: 'Consolas', monospace; font-size: .82rem;
  color: var(--text); background: var(--bg-input); padding: .05rem .35rem; border-radius: 3px;
}
.medal { font-size: 1rem; }
.empty-msg { color: var(--muted); font-size: .88rem; padding: 1rem 0; }
.pagination { display: flex; align-items: center; gap: 1rem; justify-content: center; padding-top: 1rem; border-top: 1px solid var(--border); margin-top: 1rem; }
.btn-page { background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; color: var(--text); padding: .35rem .75rem; font-size: .82rem; cursor: pointer; }
.btn-page:hover { border-color: var(--accent); }

/* ── BUTTONS ── */
.btn-create-reply {
  background: var(--accent); color: white; border: none;
  border-radius: 6px; padding: .45rem 1rem; font-size: .85rem; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.btn-create-reply:hover { background: var(--accent-h); }
.btn-cancel {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px; padding: .45rem 1rem; font-size: .85rem; cursor: pointer;
}
.btn-cancel:hover { color: var(--text); border-color: var(--muted); }
.btn-del-reply {
  background: rgba(237,66,69,.15); color: var(--red); border: none;
  border-radius: 4px; padding: .2rem .4rem; cursor: pointer; font-size: .78rem;
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 500;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal {
  background: var(--bg-modal); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
}
.modal-wide { max-width: 600px; }
.modal-title { font-size: .82rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; margin-bottom: 1rem; }
.modal-field { margin-bottom: 1rem; }
.modal-textarea {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); padding: .6rem .75rem;
  font-size: .88rem; width: 100%; min-height: 90px; resize: vertical; font-family: inherit;
}
.modal-textarea:focus { outline: none; border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1rem; }
.modal-checks { margin-bottom: 1rem; }
.check-row { display: flex; align-items: flex-start; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.check-input { width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; margin-top: 2px; cursor: pointer; }
.check-label { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.check-desc { font-size: .75rem; color: var(--muted); margin-top: .2rem; }

/* ── CHANGES BAR ── */
.changes-bar {
  position: fixed; bottom: 0; left: var(--sidebar-w); right: 0; z-index: 300;
  background: #1a1b28; border-top: 1px solid var(--border);
  display: none; align-items: center; justify-content: space-between;
  padding: .75rem 2rem; gap: 1rem;
  box-shadow: 0 -4px 24px rgba(0,0,0,.3);
}
.changes-bar.visible { display: flex; }
.changes-label { font-size: .88rem; font-weight: 500; }
.changes-actions { display: flex; gap: .75rem; }
.btn-reset {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px; padding: .4rem .9rem; font-size: .85rem; cursor: pointer;
}
.btn-reset:hover { color: var(--text); }
.btn-save {
  background: var(--green); color: #111; border: none;
  border-radius: 6px; padding: .4rem .9rem; font-size: .85rem; font-weight: 700; cursor: pointer;
}
.btn-save:hover { opacity: .9; }

/* ── TOAST ── */
.toast {
  position: fixed; top: calc(var(--topbar-h) + 1rem); right: 1rem; z-index: 999;
  background: #3a3b50; border: 1px solid var(--border); border-radius: 8px;
  padding: .6rem 1rem; font-size: .85rem; font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  animation: toastIn .2s ease;
}
.toast.error { border-color: var(--red); color: var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ── SERVER PICKER (dashboard.ejs reuse) ── */
.picker-wrap { padding: 2rem; max-width: 800px; }
.picker-title { font-size: 1.4rem; font-weight: 700; margin-bottom: .5rem; }
.picker-sub { color: var(--muted); font-size: .88rem; margin-bottom: 2rem; }
.picker-section-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .75rem; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 1rem; }
.picker-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem 1rem; text-align: center; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: .6rem;
  transition: border-color .15s, transform .15s;
}
.picker-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.picker-card-icon { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; }
.picker-card-placeholder {
  background: var(--accent); color: white; width: 52px; height: 52px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 700;
}
.picker-card-placeholder.dim { background: var(--dim); }
.picker-card-name { font-size: .82rem; font-weight: 600; line-height: 1.3; word-break: break-word; }
.picker-badge { font-size: .68rem; font-weight: 600; padding: .15rem .5rem; border-radius: 20px; }
.picker-badge.managed { background: rgba(87,242,135,.15); color: var(--green); }
.picker-badge.invite  { background: rgba(88,101,242,.15); color: var(--accent); }

/* ── LANDING / ERROR PAGES ── */
.landing-center { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: calc(100vh - var(--topbar-h)); text-align: center; padding: 2rem; gap: 2rem; }
.landing-icon { font-size: 3rem; }
.landing-title { font-size: 2rem; font-weight: 800; }
.landing-sub { color: var(--muted); font-size: 1rem; line-height: 1.6; }
.landing-features { display: flex; gap: 1rem; flex-wrap: justify-content: center; }
.feature-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; width: 160px; text-align: center; }
.feat-icon { font-size: 1.6rem; margin-bottom: .4rem; }
.feat-title { font-weight: 600; font-size: .88rem; }
.feat-desc { font-size: .75rem; color: var(--muted); margin-top: .2rem; }
.btn-discord { background: var(--accent); color: white; border: none; border-radius: 8px; padding: .7rem 1.6rem; font-size: 1rem; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: .5rem; }
.btn-discord:hover { background: var(--accent-h); }

/* ── User display with avatar ── */
.user-display {
  display: inline-flex; align-items: center; gap: .4rem;
}
.user-avatar-sm {
  width: 20px; height: 20px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.user-avatar-placeholder {
  width: 20px; height: 20px; border-radius: 50%; background: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .65rem; font-weight: 700; color: white; flex-shrink: 0;
}
