:root {
  --bg: #0b0d14;
  --bg-elev: #131623;
  --bg-elev-2: #1a1e2e;
  --border: #262b3d;
  --text: #e7e9f2;
  --text-dim: #9198b0;
  --primary: #6f5af5;
  --primary-hover: #8272ff;
  --green: #37d67a;
  --yellow: #f5c344;
  --red: #f0555c;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Roboto, -apple-system, sans-serif;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }

.topbar nav { display: flex; align-items: center; gap: 18px; font-size: 0.92rem; color: var(--text-dim); }

.topbar nav span.user { color: var(--text); }

.btn {
  display: inline-block;
  border: none;
  border-radius: var(--radius);
  padding: 9px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn:hover { border-color: var(--primary); }

.btn-primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red); color: white; }

.btn-sm { padding: 6px 12px; font-size: 0.82rem; }

.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--border); }
.btn-primary:disabled:hover { background: var(--primary); }

.container { max-width: 1080px; margin: 0 auto; padding: 32px 24px 80px; }

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
}

.auth-card h1 { font-size: 1.3rem; margin: 0 0 4px; }
.auth-card p.sub { color: var(--text-dim); margin: 0 0 24px; font-size: 0.9rem; }

label { display: block; font-size: 0.82rem; color: var(--text-dim); margin: 14px 0 6px; }

input[type=text], input[type=password], textarea, select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.92rem;
  font-family: inherit;
}

input:focus, textarea:focus { outline: none; border-color: var(--primary); }

textarea { resize: vertical; font-family: 'Consolas', monospace; font-size: 0.85rem; }

.error-box {
  background: rgba(240, 85, 92, 0.12);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.auth-card .submit { width: 100%; margin-top: 20px; }

.auth-card .switch { margin-top: 18px; text-align: center; font-size: 0.85rem; color: var(--text-dim); }
.auth-card .switch a { color: var(--primary); font-weight: 600; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-head h1 { font-size: 1.4rem; margin: 0; }

.bot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }

.bot-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bot-card .name { font-weight: 700; font-size: 1.02rem; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  width: fit-content;
}

.status-badge .pulse { width: 7px; height: 7px; border-radius: 50%; }

.status-running { background: rgba(55, 214, 122, 0.14); color: var(--green); }
.status-running .pulse { background: var(--green); }
.status-starting { background: rgba(245, 195, 68, 0.14); color: var(--yellow); }
.status-starting .pulse { background: var(--yellow); }
.status-stopped { background: rgba(145, 152, 176, 0.14); color: var(--text-dim); }
.status-stopped .pulse { background: var(--text-dim); }
.status-crashed { background: rgba(240, 85, 92, 0.14); color: var(--red); }
.status-crashed .pulse { background: var(--red); }

.bot-card .row { display: flex; gap: 8px; margin-top: auto; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
  border: 1px dashed var(--border);
  border-radius: 12px;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  margin-bottom: 20px;
}

.card h2 { font-size: 1rem; margin: 0 0 14px; }

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 12, 0.7);
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-backdrop.open { display: flex; }

.modal {
  width: 100%;
  max-width: 440px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 { margin: 0 0 4px; font-size: 1.1rem; }
.modal p.hint { color: var(--text-dim); font-size: 0.82rem; margin: 0 0 16px; }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.log-box {
  background: #05060c;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-family: 'Consolas', monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  height: 380px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: #c6cadd;
}

.back-link { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 10px; display: inline-block; }
.back-link:hover { color: var(--text); }

.bot-detail-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.bot-detail-head .row { display: flex; gap: 8px; }

.field-hint { color: var(--text-dim); font-size: 0.78rem; margin-top: 6px; }

.center-page { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--text-dim); }
