:root {
  --bg: #111318;
  --panel: #1a1d24;
  --panel-2: #222631;
  --line: #2e3340;
  --text: #e8eaf0;
  --muted: #9aa1b2;
  --accent: #5b6cff;
  --accent-2: #4757e6;
  --good: #2fbf71;
  --bad: #ef5656;
  --warn: #f0a63a;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 13px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; letter-spacing: .2px; }
.brand span { color: var(--muted); font-weight: 500; }
.account { display: flex; align-items: center; gap: 10px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2); object-fit: cover; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 120px; }

.button {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-block;
}
.button:hover { border-color: #444b5c; }
.button.primary { background: var(--accent); border-color: var(--accent); color: white; }
.button.primary:hover { background: var(--accent-2); }
.button.ghost { background: transparent; }
.button.danger { color: var(--bad); }
.button:disabled { opacity: .55; cursor: default; }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; }
.link:hover { color: var(--text); }

.hero { max-width: 460px; margin: 60px auto; text-align: center; }
.hero h1 { font-size: 28px; margin: 0 0 8px; }

.layout { display: grid; grid-template-columns: 230px 1fr; gap: 24px; align-items: start; }
.sidebar { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 4px; }
.server-select { width: 100%; margin-bottom: 12px; }
.nav button {
  width: 100%; text-align: left; background: none; border: 0; border-radius: 8px;
  padding: 9px 12px; cursor: pointer; color: var(--muted);
}
.nav button:hover { background: var(--panel); color: var(--text); }
.nav button.active { background: var(--panel-2); color: var(--text); font-weight: 600; }

.status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 14px; padding: 0 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--good); }
.dot.off { background: var(--bad); }

.section-title { margin: 0 0 4px; font-size: 22px; }
.section-help { margin: 0 0 20px; color: var(--muted); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h3 { margin: 0; font-size: 16px; }
.card-body { margin-top: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.card.off .card-body { opacity: .5; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field.wide { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: 14px; }
.field .help { font-size: 13px; color: var(--muted); }
.row-field { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.row-field:last-child { border-bottom: 0; }
.row-field .text { display: flex; flex-direction: column; }

input[type=text], input[type=number], select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 90px; resize: vertical; }
.invalid { border-color: var(--bad) !important; }
.changed { box-shadow: inset 3px 0 0 var(--warn); }

.switch { position: relative; width: 44px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span {
  position: absolute; inset: 0; background: #3a4050; border-radius: 24px; cursor: pointer; transition: .15s;
}
.switch span::before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: white; border-radius: 50%; transition: .15s;
}
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::before { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 6px 3px 10px; font-size: 13px;
}
.chip button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px; }
.chip button:hover { color: var(--bad); }
.picker { display: flex; flex-direction: column; gap: 8px; }
.inline { display: flex; gap: 8px; }

.commands-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0 24px; }
.command-name { font-family: ui-monospace, Menlo, Consolas, monospace; }

table.ladder { width: 100%; border-collapse: collapse; }
.ladder th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 6px 8px; }
.ladder td { padding: 6px 8px; border-top: 1px solid var(--line); }
.ladder input, .ladder select { min-width: 90px; }

.history { list-style: none; padding: 0; margin: 0; }
.history li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.history li:last-child { border-bottom: 0; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); margin-left: 6px; }
.badge.applied { color: var(--good); border-color: rgba(47, 191, 113, .4); }
.badge.rejected { color: var(--bad); border-color: rgba(239, 86, 86, .4); }
.badge.pending { color: var(--warn); border-color: rgba(240, 166, 58, .4); }

.notice { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; border: 1px solid var(--line); background: var(--panel); }
.notice.warn { border-color: rgba(240, 166, 58, .5); }
.notice.bad { border-color: rgba(239, 86, 86, .5); }

.savebar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); width: min(720px, calc(100% - 24px));
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: #0b0c10; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45); z-index: 10;
}
.savebar-buttons { display: flex; gap: 8px; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .nav { display: flex; overflow-x: auto; gap: 4px; }
  .nav button { width: auto; white-space: nowrap; }
  main { padding: 16px 14px 120px; }
  .savebar { flex-direction: column; align-items: stretch; }
  .savebar-buttons { justify-content: flex-end; }
}

.gap-below { margin-bottom: 10px; }
.gap-above { margin-top: 12px; }
.error-text { color: var(--bad); }
.notice.good { border-color: rgba(47, 191, 113, .5); }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; background: var(--panel-2); padding: 1px 5px; border-radius: 5px; }
.savebar[hidden] { display: none; }
.card > .card-body:first-child { margin-top: 0; }
.table-wrap { overflow-x: auto; }
@media (max-width: 760px) {
  .ladder input, .ladder select { min-width: 70px; }
  .ladder th, .ladder td { padding: 6px 4px; }
  .card-body { grid-template-columns: 1fr; }
}
.layout > * { min-width: 0; }
