:root {
  --bg: #0b1220;
  --surface: #111a2e;
  --surface-2: #17233d;
  --border: #223252;
  --text: #e7ecf5;
  --text-muted: #8791a8;
  --accent: #f5a623;
  --accent-2: #5ec8d8;
  --success: #3ddc84;
  --danger: #ef5a5a;
  --font-display: 'JetBrains Mono', ui-monospace, monospace;
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}

a { color: var(--accent-2); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  display: inline-block;
}
.brand-mark.big { width: 28px; height: 28px; margin: 0 auto 12px; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: 15px;
}

nav { display: flex; gap: 20px; }
nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  padding: 6px 2px;
  border-bottom: 2px solid transparent;
}
nav a:hover, nav a.active { color: var(--text); border-color: var(--accent); }
nav a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.page { max-width: 880px; margin: 0 auto; padding: 32px 24px 64px; }

.page-title {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.04em;
  margin-bottom: 20px;
}

/* ---- Login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 36px;
  width: 320px;
  text-align: center;
}
.login-card h1 { font-family: var(--font-display); letter-spacing: 0.15em; margin: 0 0 4px; }
.muted { color: var(--text-muted); font-size: 14px; }
.muted.small { font-size: 13px; }
.login-card form { margin-top: 24px; text-align: left; }
.login-card label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }

input[type="text"], input[type="password"], input[type="number"] {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 14px;
  margin-bottom: 16px;
}

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: #1a1305; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn.danger:hover { background: rgba(239,90,90,0.1); }
.btn.ghost { background: transparent; color: var(--accent-2); border: 1px solid var(--border); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.login-card .btn { width: 100%; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert.error { background: rgba(239,90,90,0.12); color: var(--danger); border: 1px solid rgba(239,90,90,0.3); }
.alert.success { background: rgba(61,220,132,0.12); color: var(--success); border: 1px solid rgba(61,220,132,0.3); }

/* ---- Dashboard hero ---- */
.hero-status {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  flex-wrap: wrap;
}

.status-beacon { width: 18px; height: 18px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.status-beacon[data-status="running"] { background: var(--accent); box-shadow: 0 0 14px var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.status-beacon[data-status="resting"] { background: var(--accent-2); box-shadow: 0 0 14px var(--accent-2); animation: pulse 2.6s ease-in-out infinite; }
.status-beacon[data-status="stopping"] { background: var(--accent-2); box-shadow: 0 0 14px var(--accent-2); animation: pulse 0.8s ease-in-out infinite; }
.status-beacon[data-status="error"] { background: var(--danger); box-shadow: 0 0 14px var(--danger); }
.status-beacon[data-status="idle"] { background: var(--text-muted); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.85); }
}
@media (prefers-reduced-motion: reduce) {
  .status-beacon { animation: none !important; }
}

.status-text { flex: 1; min-width: 160px; }
.status-label { font-family: var(--font-display); font-size: 20px; letter-spacing: 0.08em; }
.status-progress { font-family: var(--font-display); color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.status-actions { display: flex; gap: 10px; }

.progress-track { height: 6px; background: var(--surface-2); border-radius: 999px; margin: 20px 0; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); transition: width 0.4s ease; }

.log-panel { background: #070c17; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.log-panel-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.log-box {
  margin: 0;
  padding: 16px;
  font-family: var(--font-display);
  font-size: 12.5px;
  line-height: 1.6;
  color: #c7d2e6;
  max-height: 480px;
  overflow-y: auto;
}
.log-line {
  white-space: pre-wrap;
  word-break: break-word;
  padding-left: 11ch;
  text-indent: -11ch;
}

/* ---- Config ---- */
.config-form { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 24px; margin-bottom: 28px; }
.field { margin-bottom: 4px; }
.field label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.field-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; margin: 16px 0; }

.channel-picker { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 24px; }
.channel-picker-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; flex-wrap: wrap; gap: 10px; }
.channel-picker-header h2 { font-family: var(--font-display); font-size: 15px; margin: 0; }
.channel-list { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow-y: auto; }
.channel-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; gap: 12px; flex-wrap: wrap;
}
.channel-row .info { min-width: 0; }
.channel-row .name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-row .meta { font-family: var(--font-display); font-size: 12px; color: var(--text-muted); }
.channel-row .actions { display: flex; gap: 6px; flex-shrink: 0; }
.channel-row .actions button { font-size: 12px; padding: 6px 10px; }

@media (max-width: 640px) {
  .field-grid { grid-template-columns: 1fr 1fr; }
  .hero-status { flex-direction: column; align-items: flex-start; }
  .status-actions { width: 100%; }
  .status-actions .btn { flex: 1; }
}
