:root {
  color-scheme: dark;
  --bg: #0d1117;
  --ink: #e5e9f2;
  --muted: #a0aebc;
  --line: #2d3748;
  --panel: rgba(30, 36, 48, 0.86);
  --panel-strong: #151a23;
  --primary: #165dff;
  --secondary: #0fc6c2;
  --accent: #722ed1;
  --accent-2: #00b42a;
  --warn: #ff7d00;
  --bad: #ff5c5c;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px 1fr;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 10%, rgba(22, 93, 255, 0.22), transparent 28%),
    radial-gradient(circle at 88% 18%, rgba(15, 198, 194, 0.14), transparent 26%),
    var(--bg);
  color: var(--ink);
}

.sidebar {
  background: rgba(13, 17, 23, 0.92);
  border-right: 1px solid var(--line);
  color: #fff;
  padding: 22px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; margin-bottom: 24px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  font-size: 13px;
}
nav { display: grid; gap: 8px; }
nav button {
  height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #b8c2d4;
  text-align: left;
  padding: 0 12px;
  cursor: pointer;
}
nav button.active { background: rgba(22, 93, 255, 0.18); color: #fff; border: 1px solid rgba(15, 198, 194, 0.32); }

.app { padding: 24px; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}
h1, h2, p { margin: 0; }
h1 { font-size: 28px; }
h2 { font-size: 17px; }
.topbar p { color: var(--muted); margin-top: 6px; }
.eyebrow, .hero-kicker {
  color: var(--secondary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 6px;
}
.status-dot { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.status-dot span { width: 10px; height: 10px; background: #21a366; border-radius: 999px; }
.top-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 10px; }
.account-chip {
  min-height: 32px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--muted);
  background: rgba(30, 36, 48, 0.82);
  font-size: 13px;
}

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

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.metrics article, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(14px);
}
.metrics article { padding: 16px; }
.metrics label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.metrics strong { font-size: 30px; }
.hero-strip {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 14px;
  padding: 22px;
  border: 1px solid rgba(15, 198, 194, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(22, 93, 255, 0.18), rgba(114, 46, 209, 0.14)),
    rgba(21, 26, 35, 0.92);
}
.hero-strip h2 { font-size: 22px; margin-bottom: 8px; }
.hero-strip p { color: var(--muted); }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-actions button:first-child { background: linear-gradient(135deg, #2371ff, var(--primary)); border-color: var(--primary); color: #fff; }

.split {
  display: grid;
  grid-template-columns: 0.9fr 1.3fr;
  gap: 14px;
}
.panel { padding: 16px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
button {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(30, 36, 48, 0.9);
  color: var(--ink);
  padding: 0 12px;
  cursor: pointer;
}
#submitInstruction, #genCommand { background: var(--accent); border-color: var(--accent); color: #fff; }
.danger-btn { border-color: rgba(255, 92, 92, 0.42); color: #ffd2d2; background: rgba(255, 92, 92, 0.12); }

.agent-list, .task-list { display: grid; gap: 10px; }
.row {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  display: grid;
  gap: 8px;
  background: rgba(13, 17, 23, 0.42);
}
.row-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.row-title { font-weight: 700; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 13px; }
.pill {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  background: #eef3f8;
}
.online, .completed { color: #78f0a0; background: rgba(0, 180, 42, 0.14); }
.busy, .running, .assigned { color: #ffd091; background: rgba(255, 125, 0, 0.14); }
.offline, .failed { color: #ffb4b4; background: rgba(255, 92, 92, 0.14); }
.pending { color: #9fc8ff; background: rgba(22, 93, 255, 0.16); }

textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(13, 17, 23, 0.52);
  color: var(--ink);
  padding: 12px;
  margin: 14px 0 10px;
  font: inherit;
}
input, select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  margin: 8px 0 14px;
}
pre {
  white-space: pre-wrap;
  overflow: auto;
  background: #08101d;
  color: #e5edf8;
  border-radius: 8px;
  padding: 14px;
  min-height: 160px;
}
.copy-block { position: relative; }
.copy-block pre { padding-top: 42px; }
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  height: 28px;
  border-color: rgba(15, 198, 194, 0.35);
  color: #d9ffff;
  background: rgba(15, 198, 194, 0.12);
}
.bind-grid, .cli-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
}
.cli-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 16px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; font-weight: 700; }
.subtle { color: var(--muted); font-size: 12px; }
.tag {
  display: inline-block;
  margin: 0 4px 4px 0;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(22, 93, 255, 0.16);
  font-size: 12px;
}
.event-log {
  display: grid;
  gap: 8px;
  max-height: 560px;
  overflow: auto;
}
.feishu-card { display: grid; gap: 10px; margin-top: 14px; }
.feishu-card pre { min-height: auto; margin: 0; }

.login-body {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 24px;
}
.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}
.login-panel h1 { font-size: 24px; margin-bottom: 8px; }
.login-panel p { color: var(--muted); margin-bottom: 20px; }
.login-panel button { width: 100%; background: var(--accent); color: #fff; border-color: var(--accent); }
.login-error { min-height: 20px; color: var(--bad); margin-top: 12px; font-size: 13px; }
.version-note { margin-top: 18px; color: var(--muted); font-size: 12px; text-align: center; }
.event-log div {
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 2; }
  nav { grid-template-columns: repeat(4, 1fr); }
  nav button { text-align: center; }
  .topbar, .split, .bind-grid, .cli-grid, .hero-strip { grid-template-columns: 1fr; display: grid; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
