:root {
  --bg: #0d0d1a;
  --bg-card: #13132a;
  --bg-card-hover: #1a1a3a;
  --border: #2a2a4a;
  --border-glow: rgba(99, 102, 241, 0.25);
  --text: #e2e8f0;
  --text-muted: #6b7280;
  --text-dim: #94a3b8;
  --accent: #6366f1;
  --green: #10b981;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --red: #ef4444;
  --radius: 14px;
  --radius-sm: 8px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Header ──────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: rgba(13, 13, 26, 0.95);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon { font-size: 24px; }

.logo-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text);
}

.logo-accent { color: var(--accent); }

.version-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 20px;
  padding: 2px 8px;
  letter-spacing: 0.05em;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
}

/* ── Main ────────────────────────────────────────────────────── */
.main {
  padding: 28px;
  max-width: 1300px;
  margin: 0 auto;
}

/* ── Agents Grid ─────────────────────────────────────────────── */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  cursor: default;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.agent-card:hover {
  transform: translateY(-2px);
  border-color: var(--agent-color, var(--border));
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 0 1px var(--agent-color, transparent);
}

.card-glow {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--agent-color, transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.agent-card:hover .card-glow,
.agent-card.busy .card-glow,
.agent-card.thinking .card-glow {
  opacity: 1;
}

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.card-emoji {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}

.card-info { flex: 1; }

.card-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
}

.card-role {
  font-size: 12px;
  color: var(--text-muted);
}

.card-body { margin-top: 4px; }

.card-message {
  font-size: 13px;
  color: var(--text-dim);
  min-height: 20px;
  line-height: 1.5;
}

/* ── Status Badge ────────────────────────────────────────────── */
.status-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-badge.idle {
  background: rgba(107, 114, 128, 0.15);
  color: var(--text-muted);
  border: 1px solid rgba(107, 114, 128, 0.3);
}
.status-badge.idle::before { background: var(--text-muted); }

.status-badge.busy {
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.35);
}
.status-badge.busy::before {
  background: var(--amber);
  animation: pulse-amber 1.5s ease-in-out infinite;
}

.status-badge.thinking {
  background: rgba(59, 130, 246, 0.15);
  color: var(--blue);
  border: 1px solid rgba(59, 130, 246, 0.35);
}
.status-badge.thinking::before {
  background: var(--blue);
  animation: pulse-blue 1.2s ease-in-out infinite;
}

.status-badge.done {
  background: rgba(16, 185, 129, 0.15);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.35);
}
.status-badge.done::before { background: var(--green); }

/* ── Progress Bar ────────────────────────────────────────────── */
.progress-wrap {
  margin-top: 12px;
}

.progress-wrap.hidden { display: none; }

.progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.07);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--agent-color, var(--accent));
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ── Activity Feed ───────────────────────────────────────────── */
.activity-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.activity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.activity-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.activity-updated {
  font-size: 11px;
  color: var(--text-muted);
}

.activity-feed {
  max-height: 240px;
  overflow-y: auto;
}

.activity-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(42,42,74,0.5);
  animation: fadeIn 0.3s ease;
}

.activity-item:last-child { border-bottom: none; }

.activity-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  padding-top: 2px;
  min-width: 44px;
}

.activity-emoji { font-size: 14px; }

.activity-text {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.4;
}

.activity-agent {
  font-weight: 600;
  color: var(--text);
}

/* ── Connection Indicator ────────────────────────────────────── */
.connection-indicator {
  position: fixed;
  bottom: 16px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(19,19,42,0.9);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 11px;
  color: var(--text-muted);
  backdrop-filter: blur(8px);
}

.conn-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
  animation: pulse-amber 1.5s infinite;
}

.connection-indicator.online .conn-dot {
  background: var(--green);
  animation: none;
}

.connection-indicator.offline .conn-dot {
  background: var(--red);
  animation: none;
}

/* ── Animations ──────────────────────────────────────────────── */
@keyframes pulse-amber {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

@keyframes pulse-blue {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.4); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── New Task Button ─────────────────────────────────────────── */
.btn-new-task {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}
.btn-new-task:hover { background: #4f52d3; transform: translateY(-1px); }
.btn-new-task:active { transform: translateY(0); }

/* ── Card hint ───────────────────────────────────────────────── */
.card-hint {
  position: absolute;
  bottom: 10px;
  right: 14px;
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.2s;
}
.agent-card:hover .card-hint { opacity: 1; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: #1a1a2e;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  margin: 16px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  transform: translateY(8px);
  transition: transform 0.2s ease;
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 20px 22px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.form-select {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}
.form-select:focus { border-color: var(--accent); }

.form-textarea {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px;
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
  min-height: 110px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}
.form-textarea:focus { border-color: var(--accent); }
.form-textarea::placeholder { color: var(--text-muted); }

.form-hint {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-dim);
  min-height: 20px;
}
.form-hint.error { color: var(--red); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border);
}

.btn-cancel {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 9px 18px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.btn-cancel:hover { border-color: var(--text-muted); color: var(--text); }

.btn-submit {
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}
.btn-submit:hover { background: #4f52d3; }
.btn-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  .header { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .main { padding: 16px; }
  .header-stats { gap: 10px; }
  .stat-val { font-size: 15px; }
  .logo-text { font-size: 14px; }
  .btn-new-task { width: 100%; text-align: center; }
}
