:root {
  --bg: #1e1f22;
  --panel: #2b2d31;
  --panel-2: #313338;
  --border: #3f4147;
  --text: #f2f3f5;
  --muted: #a5a8b0;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --success: #23a55a;
  --danger: #da373c;
  --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;
}
code { background: var(--bg); padding: 1px 6px; border-radius: 4px; font-size: 13px; }
.muted { color: var(--muted); }
.error { color: #ff8a8d; }

/* Login */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--panel); padding: 32px;
  border-radius: var(--radius); display: grid; gap: 12px; text-align: center;
}
.login-card h1 { margin: 0; font-size: 22px; }
.logo { font-size: 42px; }

/* Layout */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--panel); padding: 20px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.server { display: flex; align-items: center; gap: 10px; padding: 0 8px 16px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.server img, .server .placeholder { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; }
.server strong { display: block; line-height: 1.2; }
.server small { color: var(--muted); }
.nav button {
  width: 100%; text-align: left; background: none; border: 0; color: var(--muted);
  padding: 9px 12px; border-radius: 6px; font: inherit; cursor: pointer;
}
.nav button:hover { background: var(--panel-2); color: var(--text); }
.nav button.active { background: var(--accent); color: #fff; }
.sidebar form { margin-top: auto; }

main { padding: 28px clamp(16px, 4vw, 48px) 120px; max-width: 980px; }
main h2 { margin: 0 0 4px; font-size: 24px; }
main > section > p.muted { margin-top: 0; }
section[hidden] { display: none; }

.card { background: var(--panel); border-radius: var(--radius); padding: 20px; margin: 16px 0; }
.card h3 { margin: 0 0 12px; font-size: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.stat { background: var(--panel); border-radius: var(--radius); padding: 16px; }
.stat b { display: block; font-size: 26px; }

label.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
label.field small { text-transform: none; font-weight: 400; letter-spacing: 0; }
input, select, textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 9px 10px; font: inherit; font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
textarea { min-height: 80px; resize: vertical; }
select[multiple] { min-height: 130px; }
input[type="color"] { padding: 2px; height: 40px; }

.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.toggle input { width: 42px; height: 24px; appearance: none; background: var(--border); border-radius: 12px; position: relative; cursor: pointer; border: 0; padding: 0; flex: none; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; }
.toggle input:checked { background: var(--success); }
.toggle input:checked::after { left: 21px; }
.toggle input:focus { outline-offset: 2px; }

.btn { border: 0; border-radius: 6px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; background: var(--panel-2); color: var(--text); }
.btn:hover { filter: brightness(1.15); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.success { background: var(--success); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.list-item { background: var(--panel-2); border-radius: 8px; padding: 14px; margin-bottom: 12px; display: grid; gap: 12px; }
.list-item .head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.hint { background: var(--panel-2); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 6px; font-size: 14px; color: var(--muted); }

.savebar {
  position: fixed; bottom: 20px; left: 264px; width: min(700px, calc(100vw - 288px));
  background: #111214; padding: 10px 10px 10px 18px; border-radius: var(--radius);
  display: flex; gap: 16px; align-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.savebar span { flex: 1; }
.toast { position: fixed; top: 20px; right: 20px; padding: 12px 18px; border-radius: 8px; background: var(--success); color: #fff; font-weight: 600; z-index: 10; max-width: calc(100vw - 40px); }
.toast.err { background: var(--danger); }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav button { width: auto; }
  .savebar { left: 16px; right: 16px; width: auto; }
}
