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

:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --bg3: #21262d;
  --border: rgba(255,255,255,0.08);
  --text: #e6edf3;
  --muted: #7d8590;
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
  --blue: #58a6ff;
  --purple: #bc8cff;
  --teal: #39d353;
  --radius: 14px;
}

html, body { min-height: 100%; background: var(--bg); color: var(--text); font-family: 'Inter', sans-serif; font-size: 14px; }

/* ===== HEADER ===== */
header {
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  background: var(--bg2);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.logo { display: flex; align-items: center; gap: 0.6rem; }
.logo-emoji { font-size: 1.5rem; }
.logo-title { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }
.logo-sub { font-size: 0.72rem; color: var(--muted); }

.header-right { display: flex; align-items: center; gap: 0.5rem; }
.last-updated-text { font-size: 0.75rem; color: var(--muted); }

.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
  display: inline-block;
  transition: background 0.3s;
}
.pulse-dot.live { background: var(--green); animation: pulse 2s ease-in-out infinite; }
.pulse-dot.active { background: var(--blue); animation: pulse 1s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===== MAIN ===== */
main { max-width: 960px; margin: 0 auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1.5rem; }

/* ===== AGENT CARDS ===== */
.agents { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.agent-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: border-color 0.2s;
}

.agent-card.is-active { border-color: rgba(88, 166, 255, 0.4); }
.agent-card.is-active .avatar { animation: bounce 1.5s ease-in-out infinite; }

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.card-top { display: flex; align-items: center; gap: 0.75rem; }

.avatar-wrap { position: relative; }
.avatar {
  width: 44px; height: 44px;
  background: var(--bg3);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  border: 2px solid var(--border);
}

.agent-meta { flex: 1; }
.agent-name { font-weight: 700; font-size: 0.95rem; }
.agent-owner { font-size: 0.72rem; color: var(--muted); margin-top: 1px; }

/* Status badge */
.status-badge {
  display: flex; align-items: center; gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg3);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }

.status-badge.idle .badge-dot { background: var(--muted); }
.status-badge.idle .badge-text { color: var(--muted); }

.status-badge.active { background: rgba(88,166,255,0.12); border-color: rgba(88,166,255,0.3); }
.status-badge.active .badge-dot { background: var(--blue); animation: pulse 1s ease-in-out infinite; }
.status-badge.active .badge-text { color: var(--blue); }

.status-badge.recently-active { background: rgba(63,185,80,0.1); border-color: rgba(63,185,80,0.25); }
.status-badge.recently-active .badge-dot { background: var(--green); }
.status-badge.recently-active .badge-text { color: var(--green); }

/* Task row */
.task-row {
  display: flex; align-items: flex-start; gap: 0.5rem;
  background: var(--bg3);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 0.8rem;
  min-height: 2.5rem;
}
.task-icon { font-size: 0.9rem; flex-shrink: 0; margin-top: 1px; }
.task-text { color: var(--muted); line-height: 1.5; }

/* Stats row */
.stats-row { display: flex; gap: 0.5rem; }
.stat-pill {
  flex: 1;
  background: var(--bg3);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  text-align: center;
}
.stat-val { display: block; font-size: 0.95rem; font-weight: 700; }
.stat-lbl { display: block; font-size: 0.65rem; color: var(--muted); margin-top: 1px; text-transform: uppercase; letter-spacing: 0.04em; }

/* Cron mini list */
.cron-mini { display: flex; flex-direction: column; gap: 0.3rem; }
.cron-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg3); border-radius: 6px; padding: 0.4rem 0.6rem;
  font-size: 0.72rem;
}
.cron-name { color: var(--text); font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cron-next { color: var(--muted); flex-shrink: 0; margin-left: 0.5rem; }

/* ===== SECTION HEADER ===== */
.section-header {
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.section-header h2 { font-size: 0.95rem; font-weight: 700; }
.section-sub { font-size: 0.72rem; color: var(--muted); margin-left: auto; }

/* ===== PROJECTS GRID ===== */
.projects-section { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }

.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.6rem; }

.project-card {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  text-decoration: none;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  cursor: pointer;
}
.project-card:hover { background: var(--bg); border-color: rgba(88,166,255,0.3); transform: translateY(-1px); }
.project-card .p-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.project-card .p-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-card .p-arrow { color: var(--muted); font-size: 0.7rem; flex-shrink: 0; }

.project-skeleton {
  height: 38px; background: var(--bg3); border-radius: 8px;
  animation: shimmer 1.5s ease-in-out infinite;
}
@keyframes shimmer { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ===== CHART ===== */
.chart-section { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }

.chart-totals { display: flex; gap: 1rem; margin-left: auto; }
.chart-total-item { text-align: right; }
.chart-total-val { font-size: 0.85rem; font-weight: 700; }
.chart-total-lbl { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.chart-wrap { display: flex; align-items: flex-end; gap: 4px; height: 80px; margin-top: 0.75rem; }
.chart-bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.chart-bars { display: flex; align-items: flex-end; gap: 2px; width: 100%; }
.chart-bar { flex: 1; border-radius: 3px 3px 0 0; min-height: 2px; transition: height 0.3s; }
.chart-bar.main-bar { background: var(--blue); opacity: 0.8; }
.chart-bar.steph-bar { background: var(--purple); opacity: 0.8; }
.chart-date { font-size: 0.6rem; color: var(--muted); }

/* ===== FOOTER ===== */
footer {
  text-align: center;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .agents { grid-template-columns: 1fr; }
  .projects-grid { grid-template-columns: 1fr 1fr; }
  main { padding: 1rem; }
}

/* ===== PASSWORD GATE ===== */
#gate {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
}
.gate-box {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2rem 2.5rem;
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
  width: 100%; max-width: 320px;
}
.gate-emoji { font-size: 2.5rem; }
.gate-title { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em; }
#gate-input {
  width: 100%; padding: 0.65rem 0.9rem;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 1rem;
  outline: none; text-align: center; letter-spacing: 0.1em;
}
#gate-input:focus { border-color: var(--blue); }
#gate-btn {
  width: 100%; padding: 0.65rem;
  background: var(--blue); border: none; border-radius: 8px;
  color: #fff; font-weight: 700; font-size: 0.9rem; cursor: pointer;
}
#gate-btn:hover { opacity: 0.9; }
#gate-err { font-size: 0.75rem; color: var(--red); min-height: 1rem; }
