:root {
  --bg: #0f0d1a;
  --panel: #17142a;
  --panel-2: #1f1b36;
  --line: #2c2650;
  --text: #ece9f7;
  --muted: #9a93b8;
  --accent: #a78bfa;
  --accent-2: #7c5cf0;
  --green: #34d399;
  --yellow: #fbbf24;
  --red: #f87171;
  --cyan: #67e8f9;
  --gray: #6b6588;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.spacer { height: 16px; }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 17px; padding: 0 10px 14px; }
.brand.big { font-size: 22px; padding: 0 0 12px; }
.nav a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--muted); }
.nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--panel-2); color: var(--text); }
.side .me { margin-top: auto; display: flex; gap: 8px; align-items: center; padding: 10px; border-top: 1px solid var(--line); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--panel-2); flex: none; }
.main { padding: 24px 28px; min-width: 0; }
.page-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px 16px; gap: 2px; }
  .brand { padding: 0 8px 0 0; white-space: nowrap; }
  .nav { display: flex; }
  .nav a { white-space: nowrap; }
  .side .me { margin: 0 0 0 auto; border: 0; padding: 0; }
  .side .me .who { display: none; }
  .main { padding: 16px; }
}

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 14px; }
.card.narrow { max-width: 420px; width: 100%; }
#new-bot { margin-bottom: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.bot-card { display: flex; flex-direction: column; gap: 10px; }
.bot-card .title { font-weight: 600; font-size: 16px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--panel-2); border-radius: 8px; padding: 6px 8px; }
.stat .k { font-size: 11px; color: var(--muted); }
.stat .v { font-weight: 600; }
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }

/* status pill */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 10px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--gray); }
.pill.online::before { background: var(--green); box-shadow: 0 0 8px var(--green); }
.pill.starting::before, .pill.stopping::before { background: var(--cyan); }
.pill.waiting::before { background: var(--yellow); }
.pill.crashed::before { background: var(--red); }
.tag { font-size: 11px; padding: 1px 8px; border-radius: 99px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.tag.warn { color: var(--yellow); border-color: #5c4a14; }
.tag.bad { color: var(--red); border-color: #5c2424; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; border-color: var(--line); }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.primary:hover { background: #6a48e6; }
.btn.good { color: var(--green); }
.btn.bad { color: var(--red); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.discord { background: #5865f2; border-color: #5865f2; color: #fff; justify-content: center; width: 100%; padding: 10px; font-weight: 600; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { width: 100%; font-family: var(--mono); font-size: 13px; min-height: 420px; resize: vertical; tab-size: 2; }
label.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
label.field > span { font-size: 12px; color: var(--muted); }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { width: 34px; height: 18px; appearance: none; background: var(--line); border-radius: 99px; position: relative; padding: 0; border: 0; cursor: pointer; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch input:checked { background: var(--accent-2); }
.switch input:checked::after { left: 18px; }
.switch input:disabled { opacity: .5; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* console */
.console { background: #0a0814; border: 1px solid var(--line); border-radius: var(--radius); font: 12.5px/1.45 var(--mono); padding: 12px; height: 58vh; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.console.pre { white-space: pre; overflow-x: auto; }
.console .l { display: block; }
.console .t { color: var(--gray); margin-right: 8px; }
.console .err { color: var(--red); }
.console .core { color: var(--accent); }
.console-input { display: flex; gap: 8px; margin-top: 8px; }
.console-input input { flex: 1; font-family: var(--mono); }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; background: var(--panel); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.mono, .cell { font-family: var(--mono); font-size: 12px; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }

/* files */
.crumbs { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; font-family: var(--mono); font-size: 13px; }
.crumbs a { color: var(--accent); cursor: pointer; }
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted); }
.drop.over { border-color: var(--accent); color: var(--text); }

textarea.short { min-height: 90px; font-family: inherit; font-size: 14px; }
textarea.short.mono { font-family: var(--mono); font-size: 13px; }
input.num { width: 140px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field > span:first-child { font-size: 13px; font-weight: 500; }
.chips { margin-bottom: 6px; }
.tag.chip { font-size: 12px; padding: 2px 10px; color: var(--text); }
.warn-text { color: var(--yellow); }
.save-bar { position: sticky; bottom: 0; display: flex; gap: 12px; align-items: center; padding: 12px 16px; margin-top: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 -6px 20px #0006; }
.problems { margin: 0; padding-left: 18px; color: var(--yellow); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.kv .k { color: var(--muted); }

/* toasts */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: calc(100vw - 32px); }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 10px 14px; box-shadow: 0 6px 24px #0008; max-width: 420px; }
.toast.bad { border-left-color: var(--red); }
.toast.good { border-left-color: var(--green); }
