:root {
  --bg: #0a0e17;
  --bg2: #111827;
  --panel: #151b28;
  --panel2: #1b2333;
  --border: #232c3d;
  --text: #e5edf7;
  --muted: #7d8aa3;
  --accent: #4f8cff;
  --green: #34d399;
  --red: #f87171;
  --amber: #f59e0b;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", Tahoma, system-ui, sans-serif;
  background: radial-gradient(1200px 600px at 70% -10%, #16203a 0%, var(--bg) 55%);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}
.hidden { display: none !important; }

/* ---- Login ---- */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(900px 500px at 50% 0%, #16203a, var(--bg));
}
.login-card {
  background: var(--panel); border: 1px solid var(--border);
  padding: 40px; border-radius: 18px; width: 360px; text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.login-card .logo { font-size: 46px; }
.login-card h1 { font-size: 20px; margin: 12px 0 6px; }
.login-card p { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.login-card input {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg2); color: var(--text);
  margin-bottom: 12px; font-size: 14px;
}
.login-card button {
  width: 100%; padding: 12px; border: none; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #7c5cff); color: #fff;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.login-error { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ---- App ---- */
.app { height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  background: rgba(17,24,39,.6); backdrop-filter: blur(8px);
}
.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.brand small { color: var(--muted); font-weight: 400; font-size: 11px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px var(--green); }
.stats { display: flex; gap: 10px; flex: 1; flex-wrap: wrap; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 6px 12px; font-size: 12px; }
.stat b { font-size: 15px; margin-inline-start: 6px; }
.sys { color: var(--muted); font-size: 11px; text-align: left; line-height: 1.5; }

.layout { flex: 1; display: grid; grid-template-columns: 1fr 380px; overflow: hidden; }
.graph-wrap { position: relative; }
#graph { width: 100%; height: 100%; display: block; }
.graph-hint {
  position: absolute; bottom: 14px; inset-inline-start: 50%; transform: translateX(50%);
  color: var(--muted); font-size: 12px; background: rgba(10,14,23,.7);
  padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border);
}

.side { border-inline-start: 1px solid var(--border); background: var(--bg2); overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.panel h3 { font-size: 14px; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.muted { color: var(--muted); font-size: 13px; }
.pill { background: var(--panel2); color: var(--muted); font-size: 11px; padding: 2px 8px; border-radius: 10px; }

textarea, select {
  width: 100%; background: var(--bg2); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px; padding: 10px; font-size: 13px; font-family: inherit;
}
.row { display: flex; gap: 8px; margin: 10px 0; }
.row select { flex: 1; }
.panel button {
  width: 100%; padding: 11px; border: none; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #7c5cff); color: #fff;
  font-weight: 600; cursor: pointer; font-size: 14px;
}

/* Agent detail */
.agent-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.agent-badge { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; color: #071018; }
.agent-head .meta h4 { font-size: 16px; }
.agent-head .meta span { color: var(--muted); font-size: 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; margin: 10px 0; }
.kv .k { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { background: var(--panel2); border: 1px solid var(--border); font-size: 11px; padding: 3px 9px; border-radius: 20px; color: var(--muted); }
.current-task { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-top: 10px; font-size: 12px; }
.logbox { background: #060a12; border: 1px solid var(--border); border-radius: 8px; padding: 8px; margin-top: 8px; max-height: 160px; overflow-y: auto; font-family: ui-monospace, monospace; font-size: 11px; line-height: 1.5; }

/* Task list */
.task-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.task-item { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 10px; font-size: 12px; cursor: pointer; }
.task-item:hover { border-color: var(--accent); }
.task-item .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.task-item .prompt { color: var(--text); }
.task-item .id { color: var(--muted); font-family: monospace; font-size: 10px; }
.badge { font-size: 10px; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.badge.queued { background: #3a3a1a; color: #f5d76e; }
.badge.running { background: #16324a; color: #5ac8fa; }
.badge.done { background: #14331f; color: var(--green); }
.badge.failed { background: #3a1616; color: var(--red); }
.badge.cancelled { background: #2a2a2a; color: var(--muted); }
.cancel-btn { background: transparent; border: 1px solid var(--border); color: var(--muted); border-radius: 6px; font-size: 10px; padding: 2px 6px; cursor: pointer; width: auto; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 45% 55%; }
  .side { border-inline-start: none; border-top: 1px solid var(--border); }
}
