:root {
  --bg: #17181c;
  --panel: #22242a;
  --panel-2: #2b2e35;
  --border: #33363f;
  --text: #e6e7ea;
  --muted: #9a9ea8;
  --accent: #19b5e6;
  --accent-dark: #128cb3;
  --green: #2fbf71;
  --red: #e5484d;
  --gold: #e0b03a;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px;
  background: rgba(23, 24, 28, 0.95);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 20px; }
.topbar nav { display: flex; gap: 18px; flex: 1; }
.topbar nav a { color: var(--text); }
.topbar nav a:hover { color: var(--accent); }
.user { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.user img { width: 34px; height: 34px; border-radius: 50%; }
.logout { font-size: 13px; color: var(--muted); }
.logout:hover { color: var(--red); }

main { max-width: 1160px; margin: 0 auto; padding: 24px 16px 80px; }

/* ---------- hero ---------- */
.hero {
  display: flex; align-items: center; gap: 20px;
  padding: 28px;
  margin-bottom: 20px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #2a2440 0%, #1d2a3a 100%);
  border: 1px solid var(--border);
}
.hero img { width: 72px; height: 72px; border-radius: 50%; background: var(--panel-2); }
.hero img[src=""] { visibility: hidden; }
.hero h1 { font-size: 28px; }
.hero p { margin: 4px 0 0; color: var(--muted); }

.search {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font: inherit;
}
.search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------- setup checklist ---------- */
.checklist { margin-bottom: 18px; padding: 16px 18px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.checklist-head { display: flex; align-items: baseline; gap: 12px; }
.checklist-head h2 { font-size: 17px; }
.checklist ul { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 6px; background: var(--panel-2); }
.check .icon { flex: none; width: 20px; text-align: center; }
.check .text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.check .text span:last-child { color: var(--muted); font-size: 13px; }
.check.error { border-left: 3px solid var(--red); }
.check.warn { border-left: 3px solid var(--gold); }
.check.ok { border-left: 3px solid var(--green); }

/* ---------- module cards ---------- */
.category {
  margin: 28px 0 12px;
  font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
}
.card.on { border-left-color: var(--green); }
.card.off { border-left-color: var(--red); }
.card h3 { font-size: 16px; }
.card p { margin: 0; color: var(--muted); font-size: 13.5px; flex: 1; }
.card.wide { flex-direction: row; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card.wide p { flex: none; }
.card-footer { display: flex; align-items: center; gap: 8px; }

/* ---------- buttons, badges, switches ---------- */
.btn {
  display: inline-block;
  padding: 8px 14px;
  border: 0; border-radius: 6px;
  background: var(--accent); color: #06212b;
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--accent-dark); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: wait; }
.btn-ghost { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn-ghost:hover { background: rgba(229, 72, 77, 0.15); color: var(--red); }
.btn-save { background: var(--green); color: #fff; }
.btn-save:hover { background: #24995a; }
.btn-discord { background: #5865f2; color: #fff; padding: 12px 22px; font-size: 16px; }
.btn-discord:hover { background: #4752c4; }
.btn-small { padding: 4px 10px; font-size: 13px; }

.badge {
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em;
  border: 0; cursor: pointer;
}
.badge.on { background: rgba(47, 191, 113, 0.15); color: var(--green); }
.badge.off { background: rgba(229, 72, 77, 0.15); color: var(--red); }
.badge.core { background: rgba(154, 158, 168, 0.15); color: var(--muted); cursor: default; }
.badge:not(.core):hover { filter: brightness(1.3); }

/* ---------- permissions table ---------- */
.hint { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.perm-table { width: 100%; border-collapse: collapse; background: var(--panel); }
.perm-table th, .perm-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.perm-table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); background: var(--panel-2); }
.perm-table tr:last-child td { border-bottom: 0; }
.perm-name { font-weight: 600; white-space: nowrap; }
.chip {
  display: inline-block; margin: 2px 4px 2px 0; padding: 1px 7px;
  border-radius: 4px; background: var(--panel-2); color: var(--muted);
  font-family: ui-monospace, Consolas, monospace; font-size: 12px;
}
select {
  padding: 6px 8px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font: inherit;
}

/* ---------- role dialog ---------- */
dialog {
  width: min(520px, 94vw);
  padding: 0;
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--panel); color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog-body { display: flex; flex-direction: column; gap: 10px; padding: 22px; }
.role-list { max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.role-row {
  display: flex; align-items: center; gap: 12px;
  padding: 7px 8px; border-radius: 6px; cursor: pointer;
}
.role-row:hover { background: var(--panel-2); }
.role-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex: none; }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; border-radius: 22px; background: #4a4e58; transition: background 0.15s;
}
.switch span::before {
  content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: transform 0.15s;
}
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::before { transform: translateX(16px); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ---------- settings dialog ---------- */
.settings-dialog { width: min(640px, 94vw); }
.settings-dialog .dialog-body { max-height: 88vh; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h3 { font-size: 22px; }
.close { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; }
.close:hover { color: var(--text); }
.settings-fields { overflow-y: auto; padding-right: 4px; display: flex; flex-direction: column; }
.field { padding: 14px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.field:last-child { border-bottom: 0; }
.field > label, .field-title { font-weight: 600; }
.field .hint { margin: 0; font-size: 13px; }
.field input[type="number"], .field input[type="text"], .field textarea, .field select {
  width: 100%; padding: 9px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font: inherit;
}
.field textarea { min-height: 90px; resize: vertical; }
.field-toggle { flex-direction: row; align-items: center; gap: 12px; }
.field-toggle .field-text { display: flex; flex-direction: column; gap: 2px; }
.group-title { margin: 18px 0 0; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
details.multi summary { cursor: pointer; font-weight: 600; }
details.multi summary .count { color: var(--muted); font-weight: 400; margin-left: 6px; }
details.multi .role-list { margin-top: 8px; max-height: 300px; }
.cat-title { margin: 8px 0 2px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* ---------- ticket types editor ---------- */
.type-list { display: flex; flex-direction: column; gap: 10px; margin: 8px 0; }
.type-card { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); }
.type-card input[type="text"], .type-card select {
  width: 100%; padding: 8px 9px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font: inherit;
}
.type-head { display: flex; align-items: center; gap: 8px; }
/* more specific than ".field input[type=text]" (width: 100%), which pushed the name field out of the box */
.type-card .type-head input.emoji-input { width: 64px; flex: none; text-align: center; }
.type-card .type-head input.name-input { width: auto; flex: 1; min-width: 0; }
.type-enabled { display: flex; align-items: center; }
.type-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.type-row label { display: flex; flex-direction: column; gap: 4px; }
.type-row.three { grid-template-columns: repeat(3, 1fr); }
.rune-row { display: flex; flex-direction: column; gap: 6px; padding: 8px; border-left: 3px solid #8a6cff; background: rgba(138, 108, 255, 0.06); border-radius: 6px; }
.type-card textarea { width: 100%; min-height: 64px; }
.type-row.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 640px) { .type-row.three, .type-row.four { grid-template-columns: 1fr 1fr; } }
.mini-label { font-size: 12px; color: var(--muted); }
.icon-btn { flex: none; width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel); color: var(--text); cursor: pointer; }
.icon-btn:hover { border-color: var(--accent); }
.icon-btn.danger:hover { border-color: var(--red); color: var(--red); }
.type-card details.multi .role-list { max-height: 200px; }

/* ---------- role menus editor ---------- */
.type-card textarea { width: 100%; min-height: 60px; padding: 8px 9px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font: inherit; resize: vertical; }
.menu-roles { display: flex; flex-direction: column; gap: 6px; }
.menu-role { display: grid; grid-template-columns: 64px 1fr 1fr 30px; gap: 6px; align-items: center; }
.type-card .menu-role input.emoji-input { width: 64px; text-align: center; }
@media (max-width: 640px) { .menu-role { grid-template-columns: 54px 1fr 30px; } .menu-role input:not(.emoji-input) { grid-column: 2 / 4; } }

/* ---------- role triggers editor ---------- */
.tier-row { display: grid; grid-template-columns: auto 70px auto 1fr 30px; gap: 8px; align-items: center; }
.type-card input.count-input { width: 70px; }
.inline-toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.step-row { display: grid; grid-template-columns: auto 70px auto 1fr 90px 30px; gap: 8px; align-items: center; }
.type-card input[type="datetime-local"] { width: 100%; padding: 7px 9px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font: inherit; color-scheme: dark; }

/* ---------- backup ---------- */
.backup-actions { display: flex; gap: 10px; flex: none; }
.btn-ghost-blue { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-ghost-blue:hover { background: rgba(25, 181, 230, 0.12); color: var(--accent); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px);
  padding: 10px 18px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--border);
  transition: transform 0.2s;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--red); color: #ffb3b5; }

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-box {
  max-width: 420px; padding: 36px; text-align: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
}
.login-box .logo { font-size: 42px; }
.login-box p { color: var(--muted); margin: 10px 0 24px; }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .topbar nav { order: 3; width: 100%; }
  .hero { padding: 18px; }
  .card.wide { flex-direction: column; align-items: flex-start; }
}

/* commands & categories */
.subhead { margin: 28px 0 6px; font-size: 16px; }
.cmd-module { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.cmd-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; flex-wrap: wrap; }
.cmd-toggle { background: none; border: 0; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; padding: 4px 0; }
.cmd-count { margin: 0; }
.cmd-controls { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.cmd-module .table-wrap { border-radius: 0; border: 0; border-top: 1px solid var(--border); margin: 0; }
.cmd-desc { margin: 0; max-width: 420px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.hint.ok { color: var(--green); }
.hint.warn { color: var(--gold); }
h3 .hint { font-size: 13px; font-weight: 400; margin: 0; }

/* raid days */
.day-pills { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; }
.day-pill { position: relative; cursor: pointer; }
.day-pill input { position: absolute; opacity: 0; pointer-events: none; }
.day-pill span { display: inline-block; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border, #444);
  font-size: 13px; user-select: none; }
.day-pill input:checked + span { background: var(--accent, #5865f2); border-color: var(--accent, #5865f2); color: #fff; }
.day-pill input:focus-visible + span { outline: 2px solid var(--accent, #5865f2); outline-offset: 2px; }
.entry-summary { flex: 1; margin: 0; font-weight: 600; }

/* scaling previews */
.preview-box { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin: 6px 0; }
.preview-box .tier-row select { max-width: 200px; }
.table-scroll { overflow-x: auto; max-width: 100%; }
.scale-table { border-collapse: collapse; font-size: 13px; margin: 4px 0 8px; }
.scale-table th, .scale-table td { padding: 3px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
.scale-table thead th { font-weight: 600; }
.scale-table tbody th { text-align: left; font-weight: 500; }
.scale-guide { margin: 4px 0 12px; }
.scale-guide summary { cursor: pointer; font-weight: 600; margin-bottom: 6px; }
.scale-guide p { margin: 6px 0; }

/* links to the public pages on the login page */
.login-links { display: flex; justify-content: center; gap: 18px; margin-top: 22px; flex-wrap: wrap; }
.login-links a { color: var(--muted); }
.login-links a:hover { color: var(--accent); }
