:root {
  --bg: #0b0d12;
  --bg2: #12151d;
  --glass: rgba(22, 26, 36, 0.72);
  --glass-strong: rgba(18, 21, 29, 0.92);
  --stroke: rgba(162, 155, 254, 0.22);
  --stroke2: rgba(0, 206, 201, 0.28);
  --text: #e8eaf0;
  --muted: #9aa3b5;
  --accent: #a29bfe;
  --accent2: #00cec9;
  --danger: #ff7675;
  --ok: #55efc4;
  --warn: #ffeaa7;
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --nav-w: 248px;
  --topbar-h: 64px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --trans: 180ms ease;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font); min-height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(162,155,254,.18), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(0,206,201,.12), transparent 55%),
    var(--bg);
}
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; }
code, .mono { font-family: var(--mono); font-size: .88em; }

.shell {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns var(--trans);
}
.shell.nav-collapsed { grid-template-columns: 0 1fr; }
.shell.nav-collapsed .nav { transform: translateX(-100%); opacity: 0; pointer-events: none; }

.nav {
  position: sticky; top: 0; height: 100vh; padding: 1.15rem .9rem 1.5rem;
  background: rgba(10,12,18,.88); border-right: 1px solid var(--stroke);
  backdrop-filter: blur(14px); overflow-y: auto; z-index: 40;
  transition: transform var(--trans), opacity var(--trans);
}
.brand { display: flex; gap: .75rem; align-items: center; margin-bottom: 1.25rem; padding: .25rem .35rem; }
.brand img { width: 40px; height: 40px; border-radius: 10px; }
.brand h1 { font-size: .98rem; margin: 0; letter-spacing: .02em; font-weight: 700; }
.brand small { color: var(--muted); display: block; font-size: .72rem; }
.nav-links { display: flex; flex-direction: column; gap: .15rem; }
.nav a.item {
  display: block; padding: .62rem .78rem; border-radius: var(--radius-sm); color: var(--text);
  border: 1px solid transparent; transition: background var(--trans), border-color var(--trans);
}
.nav a.item:hover, .nav a.item.active {
  background: var(--glass); border-color: var(--stroke); text-decoration: none;
}
.nav a.item.active {
  background: linear-gradient(135deg, rgba(162,155,254,.18), rgba(0,206,201,.1));
  border-color: var(--stroke2);
}
.nav-foot { margin-top: 1.5rem; font-size: .72rem; padding: 0 .4rem; }

.workspace { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: .85rem;
  min-height: var(--topbar-h); padding: .75rem 1.25rem;
  background: rgba(11,13,18,.78); border-bottom: 1px solid var(--stroke);
  backdrop-filter: blur(14px);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h2 { margin: 0; font-size: 1.1rem; font-weight: 650; }
.topbar-title p { margin: .1rem 0 0; font-size: .8rem; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--stroke);
  background: var(--glass); color: var(--text); cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); }
.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .28rem .7rem; border-radius: 999px; font-size: .75rem; font-weight: 600;
  border: 1px solid var(--stroke); background: var(--glass); color: var(--muted);
}
.pill.ok { color: var(--ok); border-color: rgba(85,239,196,.35); }
.pill.err { color: var(--danger); border-color: rgba(255,118,117,.4); }

.main { padding: 1.25rem 1.5rem 3rem; max-width: 1180px; width: 100%; margin: 0 auto; outline: none; }
.hero {
  background: var(--glass); border: 1px solid var(--stroke); border-radius: var(--radius);
  padding: 1.25rem 1.4rem; margin-bottom: 1.1rem; backdrop-filter: blur(16px);
}
.hero h2, .hero h3 { margin: 0 0 .35rem; font-weight: 650; }
.hero p { margin: 0; color: var(--muted); }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  background: var(--glass); border: 1px solid var(--stroke); border-radius: var(--radius);
  padding: 1.05rem 1.15rem; backdrop-filter: blur(14px);
  transition: border-color var(--trans), transform var(--trans);
}
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--accent); transform: translateY(-1px); }
.card h3 { margin: 0 0 .5rem; font-size: 1rem; }
.card .val {
  font-size: 1.55rem; font-weight: 700;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.muted { color: var(--muted); font-size: .9rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .65rem; align-items: center; margin-bottom: 1rem; }
.toolbar .grow { flex: 1; min-width: 160px; }
.filters { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .9rem; }
.chip {
  border: 1px solid var(--stroke); background: transparent; color: var(--muted);
  border-radius: 999px; padding: .35rem .7rem; cursor: pointer; font-size: .8rem; font-weight: 600;
}
.chip:hover, .chip.active {
  color: var(--text); border-color: var(--accent2);
  background: rgba(0,206,201,.12);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid var(--stroke);
  background: linear-gradient(135deg, rgba(162,155,254,.25), rgba(0,206,201,.15));
  color: var(--text); padding: .62rem 1rem; border-radius: 999px; cursor: pointer; font-weight: 600;
  transition: filter var(--trans);
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; }
.btn.danger { background: rgba(255,118,117,.15); border-color: rgba(255,118,117,.4); }
.btn.ok { background: rgba(85,239,196,.12); border-color: rgba(85,239,196,.35); }
.btn.sm { padding: .4rem .75rem; font-size: .82rem; }
.btn.block { width: 100%; }

label { display: block; font-size: .82rem; color: var(--muted); margin-top: .35rem; }
input, textarea, select {
  width: 100%; background: #0e1118; border: 1px solid var(--stroke); color: var(--text);
  border-radius: var(--radius-sm); padding: .68rem .8rem; margin: .3rem 0 .7rem;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(162,155,254,.15);
}
textarea { resize: vertical; min-height: 96px; font-family: var(--mono); font-size: .86rem; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .55rem .4rem; border-bottom: 1px solid rgba(255,255,255,.06); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }

.badge {
  display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .72rem;
  border: 1px solid var(--stroke); color: var(--accent); font-weight: 600; white-space: nowrap;
}
.badge.s1 { color: #a29bfe; } .badge.s2 { color: #74b9ff; } .badge.s3 { color: #00cec9; }
.badge.s4 { color: #55efc4; } .badge.s5 { color: #ffeaa7; } .badge.s6 { color: #fd79a8; }
.badge.s7 { color: #e17055; } .badge.s8 { color: #81ecec; }

.agent-grid, .skill-grid {
  display: grid; gap: .75rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.agent-card .name, .skill-card .name { font-weight: 650; margin: .35rem 0 .2rem; }
.agent-card .id, .skill-card .id { font-family: var(--mono); font-size: .75rem; color: var(--muted); }

.plans { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.plan.featured { border-color: var(--accent2); box-shadow: 0 0 0 1px rgba(0,206,201,.25); }
.plan ul { padding-left: 1.1rem; color: var(--muted); margin: .6rem 0 1rem; }
.plan .price { font-size: 1.7rem; font-weight: 700; margin: .35rem 0; }

pre, .code {
  background: #0e1118; border: 1px solid var(--stroke); border-radius: 12px; padding: 1rem;
  overflow: auto; white-space: pre-wrap; font-size: .84rem; font-family: var(--mono);
}
.timeline { display: flex; flex-direction: column; gap: .85rem; }
.timeline-item {
  position: relative; padding-left: 1.1rem; border-left: 2px solid var(--stroke);
}
.timeline-item::before {
  content: ""; position: absolute; left: -5px; top: .45rem;
  width: 8px; height: 8px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
}
.timeline-item h4 { margin: 0 0 .25rem; font-size: .95rem; }
.timeline-meta { font-size: .75rem; color: var(--muted); margin-bottom: .35rem; }

.bars { display: flex; flex-direction: column; gap: .55rem; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 48px; gap: .5rem; align-items: center; font-size: .85rem; }
.bar-track { height: 8px; background: #0e1118; border-radius: 999px; overflow: hidden; border: 1px solid var(--stroke); }
.bar-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

.state {
  padding: 2rem 1rem; text-align: center; color: var(--muted);
  border: 1px dashed var(--stroke); border-radius: var(--radius); margin: .5rem 0;
}
.state.error { color: var(--danger); border-color: rgba(255,118,117,.35); }
.state.loading::after {
  content: ""; display: inline-block; width: 14px; height: 14px; margin-left: .5rem;
  border: 2px solid var(--stroke); border-top-color: var(--accent2); border-radius: 50%;
  animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.fade-in { animation: fadeIn .22s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50;
}
.drawer {
  position: fixed; top: 0; right: 0; width: min(420px, 100vw); height: 100vh;
  background: var(--glass-strong); border-left: 1px solid var(--stroke);
  backdrop-filter: blur(18px); z-index: 60; padding: 1.25rem; overflow-y: auto;
  box-shadow: var(--shadow); animation: slideIn .2s ease;
}
@keyframes slideIn { from { transform: translateX(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; margin-bottom: 1rem; }
.drawer-head h3 { margin: 0; }

.toast {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 80;
  background: #161a24; border: 1px solid var(--stroke); padding: .8rem 1rem;
  border-radius: 12px; display: none; max-width: min(360px, calc(100vw - 2rem));
  box-shadow: var(--shadow);
}
.toast.show { display: block; animation: fadeIn .2s ease; }

.quick-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .85rem; }
.gh-card { display: flex; gap: 1rem; align-items: flex-start; }
.gh-card img { width: 72px; height: 72px; border-radius: 16px; border: 1px solid var(--stroke); }
.row-actions { display: flex; flex-wrap: wrap; gap: .4rem; }

@media (max-width: 960px) {
  .grid-2 { grid-template-columns: 1fr; }
  .shell { grid-template-columns: 1fr; }
  .nav {
    position: fixed; left: 0; top: 0; width: min(280px, 86vw); height: 100vh;
    transform: translateX(-105%); opacity: 0; pointer-events: none;
  }
  .shell.nav-open .nav { transform: none; opacity: 1; pointer-events: auto; }
  .shell.nav-open::after {
    content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35;
  }
}
@media (max-width: 560px) {
  .main { padding: 1rem 1rem 2.5rem; }
  .topbar { padding: .65rem .85rem; }
  .bar-row { grid-template-columns: 1fr; }
}
