/* ---- Variables ---- */
:root {
  --bg:       #0d1117;
  --card:     #161b22;
  --card-hover: #1c2128;
  --border:   #21262d;
  --txt:      #f0f6fc;
  --muted:    #8b949e;
  --dim:      #484f58;

  --purple:   #7c3aed;
  --purple-h: rgba(124,58,237,.2);
  --purple-t: #a78bfa;

  --blue:     #3b82f6;
  --blue-h:   rgba(59,130,246,.2);
  --blue-t:   #93c5fd;

  --teal:     #0891b2;
  --teal-h:   rgba(8,145,178,.2);
  --teal-t:   #67e8f9;

  --gold:     #fbbf24;
  --gold-h:   rgba(251,191,36,.2);

  --green:    #3fb950;
  --green-h:  rgba(63,185,80,.15);
  --red:      #f85149;
  --red-h:    rgba(248,81,73,.15);
  --yellow:   #e3b341;

  --radius:   10px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--txt);
  line-height: 1.5;
  min-height: 100vh;
}

#app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 20px 48px;
}

/* ---- Header ---- */
header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { font-size: 2em; line-height: 1; }
h1 { font-size: 2.2em; font-weight: 700; letter-spacing: -0.02em; }

.hdr-right { display: none; }
.footer-status { display: flex; align-items: center; gap: 6px; }

/* ---- Status dots ---- */
.dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}
.dot-green  { background: var(--green);  color: var(--green); }
.dot-red    { background: var(--red);    color: var(--red); }
.dot-yellow { background: var(--yellow); color: var(--yellow); }

/* ---- Stats bar ---- */
#stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
}

.stat-value {
  font-size: 2em;
  font-weight: 700;
  color: var(--blue);
  line-height: 1.1;
}
.stat-value.warn { color: var(--red); }
.stat-value.ok   { color: var(--green); }

.stat-label {
  font-size: .76em;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: 4px;
}

/* ---- Section titles ---- */
.section-title {
  font-size: 1.05em;
  font-weight: 600;
  margin: 28px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sub-title {
  font-size: .82em;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 16px 0 8px;
}

/* ---- Badges ---- */
.badge {
  font-size: .7em;
  padding: 2px 9px;
  border-radius: 12px;
  font-weight: 600;
  display: inline-block;
  white-space: nowrap;
  line-height: 1.6;
}

.badge-purple { background: var(--purple-h); color: var(--purple-t); }
.badge-blue   { background: var(--blue-h);   color: var(--blue-t); }
.badge-teal   { background: var(--teal-h);   color: var(--teal-t); }
.badge-gold   { background: var(--gold-h);   color: var(--gold); }
.badge-gray   { background: rgba(139,148,158,.14); color: var(--muted); }
.badge-red    { background: var(--red-h);    color: #fca5a5; }
.badge-green  { background: var(--green-h);  color: var(--green); }
.badge-sys    { background: var(--blue-h);   color: var(--blue-t); }

/* ---- Agents grid ---- */
.agents-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 4px;
}

.agent-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color .18s, background .18s;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0;
  flex: 0 0 280px;
  width: 280px;
}

.agent-card:hover {
  background: var(--card-hover);
  border-color: var(--blue);
}

.agent-card.active {
  border-left: 3px solid var(--green);
}

.agent-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
}

.agent-emoji { font-size: 1.6em; line-height: 1; flex-shrink: 0; }

.agent-title { flex: 1; min-width: 0; }
.agent-name  { font-weight: 600; font-size: .98em; }

.agent-strategy {
  font-size: .77em;
  color: var(--muted);
  margin-bottom: 9px;
  min-height: 1.1em;
}

.agent-model {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  margin-bottom: 9px;
}

.fallback-label {
  font-size: .68em;
  color: var(--dim);
}

/* Trade state block */
.trade-state {
  background: rgba(255,255,255,.03);
  border-radius: 7px;
  padding: 8px 10px;
  margin-bottom: 9px;
}

.pnl-pos { color: var(--green); font-weight: 600; font-size: .88em; }
.pnl-neg { color: var(--red);   font-weight: 600; font-size: .88em; }
.trade-meta { display: block; font-size: .72em; color: var(--muted); margin-top: 2px; }

/* Cron count pill */
.agent-footer { margin-top: auto; padding-top: 6px; margin-bottom: 6px; }
.pill-active {
  font-size: .72em;
  background: var(--green-h);
  color: var(--green);
  padding: 2px 9px;
  border-radius: 12px;
  display: inline-block;
}
.pill-inactive { font-size: .72em; color: var(--dim); }

/* ---- Crons table ---- */
.table-wrap { overflow-x: auto; margin-bottom: 4px; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
}

th {
  background: var(--card-hover);
  color: var(--muted);
  font-size: .73em;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: .86em;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr.row-disabled td { opacity: .38; }
tr:not(.row-disabled):hover td { background: rgba(255,255,255,.02); }

.mono { font-family: 'SFMono-Regular', Consolas, monospace; font-size: .82em; color: var(--muted); }
.time-dim { color: var(--dim); font-size: .8em; }
.err-count { color: var(--red); font-weight: 600; }

/* System crons */
.sys-cron-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: .84em;
}
.sys-cron-row:last-child { border-bottom: none; }
.sys-cron-row code { color: var(--muted); font-family: monospace; font-size: .82em; }
.sys-cron-name { color: var(--dim); }

/* ---- Providers grid ---- */
.providers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.provider-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.provider-icon { font-size: 1.8em; margin-bottom: 8px; line-height: 1; }
.provider-name { font-weight: 600; margin-bottom: 4px; }

.provider-status {
  font-size: .82em;
  font-weight: 600;
  margin-bottom: 6px;
}
.provider-status.ok { color: var(--green); }
.provider-status.er { color: var(--red); }

.provider-detail { font-size: .75em; color: var(--muted); margin-bottom: 2px; }

.profile-pill {
  display: inline-block;
  margin-top: 6px; margin-right: 4px;
  font-size: .7em;
  background: var(--blue-h);
  color: var(--blue-t);
  padding: 2px 9px;
  border-radius: 10px;
}

/* ---- Skills & Scripts ---- */
.skills-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.skill-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 7px;
  font-size: .84em;
}

.skill-doc { color: var(--blue); font-size: .68em; margin-left: auto; }
.script-owner { font-size: .68em; color: var(--muted); margin-left: auto; white-space: nowrap; }

/* ---- Footer ---- */
footer {
  margin-top: 44px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: .75em;
  color: var(--dim);
  flex-wrap: wrap;
  gap: 8px;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  #stats-bar { grid-template-columns: repeat(2, 1fr); }
  .providers-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .agents-grid { grid-template-columns: 1fr; }
  .skills-grid { grid-template-columns: 1fr; }
  .providers-grid { grid-template-columns: 1fr; }
  header { flex-direction: column; align-items: flex-start; gap: 10px; }
  h1 { font-size: 1.3em; }
  footer { flex-direction: column; }
}

/* ── Gateway block ───────────────────────────────────────────────────────── */
.gateway-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.gateway-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.gateway-icon { font-size: 1.4em; }
.gateway-name { font-weight: 600; }
.gateway-details {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: .83em;
}
.gw-detail code {
  color: var(--fg);
  background: var(--hover);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: .95em;
}
.skill-unused { font-size: .68em; color: var(--dim); margin-left: auto; font-style: italic; }

/* ── Team groups ─────────────────────────────────────────────────────────── */
.team-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px 14px;
}
.team-group.team-grok      { border-color: rgba(168,129,255,.35); background: rgba(168,129,255,.04); }
.team-group.team-claude    { border-color: rgba(56,189,132,.30);  background: rgba(56,189,132,.03);  }
.team-group.team-openclaw  { border-color: rgba(245,158,11,.35);  background: rgba(245,158,11,.04);  }

.team-label {
  font-size: .72em;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.team-group.team-grok      .team-label { color: rgba(168,129,255,.9); }
.team-group.team-claude    .team-label { color: rgba(56,189,132,.9);  }
.team-group.team-openclaw  .team-label { color: rgba(245,158,11,.9);   }

.team-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}

/* ── Boss card ───────────────────────────────────────────────────────────── */
.agent-card.boss {
  border-color: var(--gold);
  border-width: 2px;
  background: linear-gradient(135deg, var(--card) 60%, rgba(251,191,36,.07));
  box-shadow: 0 0 18px rgba(251,191,36,.12);
}
.agent-card.boss .agent-emoji { font-size: 1.6em; }
.agent-card.boss .agent-name  { font-size: 1.08em; }
.team-group.team-first { border-color: rgba(251,191,36,.30); background: rgba(251,191,36,.03); }
.team-group.team-first .team-label { color: rgba(251,191,36,.9); }

/* ── Standalone agent (Boss) centering ──────────────────────────────────── */
.standalone-wrap {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
}

