*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:       #0e1117;
  --surface:  #181d27;
  --surface2: #1f2535;
  --border:   #2a3145;
  --accent:   #3b82f6;
  --success:  #22c55e;
  --danger:   #ef4444;
  --warning:  #f59e0b;
  --text:     #e2e8f0;
  --muted:    #94a3b8;
  --code-bg:  #0d1117;
  --radius:   6px;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1100px;
  margin: 0 auto;
}

header h1 {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Bot indicator pill */
.indicator {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid var(--border);
}

.indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.indicator.running  { border-color: var(--success); color: var(--success); }
.indicator.running .dot  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.indicator.stopped  { border-color: var(--muted);   color: var(--muted); }
.indicator.stopped .dot  { background: var(--muted); }

/* ── Tab nav ── */
.tab-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  gap: 0;
  overflow-x: auto;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.75rem 1.1rem;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover  { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Main & panels ── */
main {
  flex: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
  width: 100%;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.tab-panel > h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.desc {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 1.2rem;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.5rem;
  margin-bottom: 1rem;
}

.card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text);
}

/* ── Fieldsets ── */
fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
}

legend {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 0.4rem;
}

/* ── Form fields ── */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.85rem;
}

.field-group:last-child { margin-bottom: 0; }

label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="date"],
select,
input[type="number"] {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: 0.85rem;
  padding: 0.45rem 0.7rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, select:focus {
  border-color: var(--accent);
}

small {
  color: var(--muted);
  font-size: 0.75rem;
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ── Buttons ── */
.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.85rem 0 0.5rem;
}

.btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 0.83rem;
  font-weight: 500;
  padding: 0.45rem 1rem;
  transition: background 0.15s, border-color 0.15s;
}

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

.btn.primary { background: var(--accent);  border-color: var(--accent);  color: #fff; }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.danger  { background: var(--danger);  border-color: var(--danger);  color: #fff; }

.btn.primary:hover { filter: brightness(1.1); }
.btn.success:hover { filter: brightness(1.1); }
.btn.danger:hover  { filter: brightness(1.1); }

.btn.small { padding: 0.3rem 0.6rem; font-size: 0.78rem; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Preset buttons ── */
.preset-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.preset.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Status card ── */
.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.status-badge {
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.3rem 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.status-badge.running { background: rgba(34,197,94,0.15); color: var(--success); border: 1px solid var(--success); }
.status-badge.stopped { background: rgba(148,163,184,0.1); color: var(--muted);   border: 1px solid var(--border); }

.status-detail { font-size: 0.8rem; color: var(--muted); }

/* ── Log boxes ── */
.log-container {
  margin-top: 1rem;
}

.log-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.log-header select {
  width: auto;
  padding: 0.2rem 0.4rem;
  font-size: 0.78rem;
}

.log-box {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: #7dd3fc;
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: 0.75rem;
  line-height: 1.5;
  max-height: 320px;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-box.small { max-height: 180px; }

/* ── Messages ── */
.msg {
  font-size: 0.82rem;
  margin-top: 0.5rem;
  min-height: 1.2em;
}

.msg.ok  { color: var(--success); }
.msg.err { color: var(--danger); }

/* ── Footer ── */
footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
  padding: 0.75rem 1.5rem;
  text-align: center;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .row2 { grid-template-columns: 1fr; }
  .tab-btn { padding: 0.65rem 0.75rem; font-size: 0.8rem; }
}

/* ── Login page ── */
.login-body {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
}

.login-main {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.login-logo {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.3rem;
}

.login-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.login-sub {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 1.8rem;
}

.login-btn {
  width: 100%;
  padding: 0.6rem;
  font-size: 0.92rem;
}

/* ── Modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-backdrop.hidden { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.modal h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1.2rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.2rem;
}

/* ── Logout button in header ── */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-logout {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 0.3rem 0.7rem;
  transition: color 0.15s, border-color 0.15s;
}

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