:root {
  --bg: #0b0d12;
  --bg2: #11141b;
  --bg3: #171b24;
  --border: #232836;
  --text: #e6e9f0;
  --muted: #8b93a7;
  --accent: #8b5cf6;
  --accent2: #a78bfa;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: dark; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
button {
  font: inherit; cursor: pointer; border: 1px solid var(--border);
  background: var(--bg3); color: var(--text); border-radius: 8px;
  padding: 8px 14px; transition: background .15s, border-color .15s;
}
button:hover { background: #1e2431; border-color: #33405a; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #7c4ff0; }
button.danger { background: transparent; border-color: var(--red); color: var(--red); }
button.danger:hover { background: rgba(239,68,68,.12); }
button.ghost { background: transparent; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea {
  font: inherit; background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }
.boot { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; gap: 16px; color: var(--muted); }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Landing */
.landing { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at top, #1a1430 0%, var(--bg) 60%); }
.landing-card { text-align: center; max-width: 560px; padding: 40px; }
.logo { font-size: 52px; font-weight: 800; letter-spacing: -1px; background: linear-gradient(90deg, var(--accent2), #22d3ee); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { color: var(--muted); font-size: 18px; margin: 8px 0 32px; }
.btn-discord { display: inline-flex; align-items: center; gap: 10px; background: #5865f2; color: #fff; border: none; padding: 13px 28px; border-radius: 10px; font-size: 16px; font-weight: 600; }
.btn-discord:hover { background: #4752c4; }

/* Layout */
.topbar { display: flex; align-items: center; gap: 14px; padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--bg2); position: sticky; top: 0; z-index: 10; }
.topbar .brand { font-weight: 700; font-size: 18px; }
.topbar .brand span { color: var(--accent2); }
.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.user-chip img { width: 28px; height: 28px; border-radius: 50%; }
.layout { display: flex; min-height: calc(100vh - 57px); }
.sidebar { width: 230px; border-right: 1px solid var(--border); padding: 16px 10px; background: var(--bg2); flex-shrink: 0; }
.sidebar a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--muted); font-size: 14px; margin-bottom: 2px; }
.sidebar a.active, .sidebar a:hover { background: var(--bg3); color: var(--text); text-decoration: none; }
.main { flex: 1; padding: 24px; min-width: 0; }
.crumb { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.crumb a { color: var(--muted); }
h1 { font-size: 24px; margin-bottom: 4px; }
.sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; }

/* Cards & stats */
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat .num { font-size: 30px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:hover td { background: rgba(255,255,255,.02); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.submitted { background: rgba(245,158,11,.15); color: var(--amber); }
.badge.under_review { background: rgba(59,130,246,.15); color: var(--blue); }
.badge.interview_required { background: rgba(139,92,246,.15); color: var(--accent2); }
.badge.accepted { background: rgba(34,197,94,.15); color: var(--green); }
.badge.rejected { background: rgba(239,68,68,.15); color: var(--red); }
.badge.withdrawn { background: rgba(107,114,128,.15); color: var(--muted); }
.badge.open { background: rgba(34,197,94,.15); color: var(--green); }
.badge.closed, .badge.draft { background: rgba(107,114,128,.15); color: var(--muted); }

/* Server list */
.server-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg2); margin-bottom: 10px; }
.server-row img, .server-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--bg3); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--accent2); flex-shrink: 0; }
.server-row .name { font-weight: 600; }
.server-row .meta { color: var(--muted); font-size: 13px; }
.server-row .actions { margin-left: auto; display: flex; gap: 8px; }

/* Forms builder */
.q-row { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; background: var(--bg3); }
.q-row .q-main { flex: 1; }
.q-row .q-label { font-weight: 600; }
.q-row .q-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.q-row .q-opts { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* Detail */
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } .sidebar { display: none; } }
.answer-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.answer-item .q { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.answer-item .a { margin-top: 4px; white-space: pre-wrap; word-break: break-word; }
.note-item { padding: 10px; background: var(--bg3); border-radius: 8px; margin-bottom: 8px; font-size: 14px; }
.note-item .meta { color: var(--muted); font-size: 11px; margin-top: 5px; }
.hist-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.hist-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 5px; flex-shrink: 0; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 16px; color: var(--muted); white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

/* Misc */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 10px; }
.error-box { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.4); color: #fca5a5; padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; }
.success-box { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.4); color: #86efac; padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: 14px; padding: 24px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal h3 { margin-bottom: 8px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 14px; color: var(--muted); font-size: 13px; }
.chart-bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding-top: 10px; }
.chart-bars .bar { flex: 1; background: linear-gradient(180deg, var(--accent), #4c1d95); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.chart-bars .bar:hover::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--bg3); border: 1px solid var(--border); padding: 4px 8px; border-radius: 6px; font-size: 11px; white-space: nowrap; z-index: 5; }
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv .k { color: var(--muted); }
#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--bg3); border: 1px solid var(--border); border-left: 3px solid var(--accent); padding: 12px 18px; border-radius: 10px; font-size: 14px; animation: slidein .2s ease; max-width: 360px; }
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }
