:root {
  --bg: #09090b;
  --surface: rgba(15, 15, 18, 0.8);
  --surface-solid: #0f0f12;
  --surface-hover: rgba(25, 25, 30, 0.8);
  --border: rgba(255, 255, 255, 0.06);
  --text: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #52525b;
  --purple: #9945FF;
  --purple-hover: #8033e0;
  --purple-glow: rgba(153, 69, 255, 0.2);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.12);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.12);
  --yellow: #eab308;
  --yellow-dim: rgba(234, 179, 8, 0.12);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.12);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --sidebar-w: 240px;
  --topbar-h: 56px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { font-family: var(--font); background: var(--bg); color: var(--text); display: flex; min-height: 100vh; overflow-x: hidden; }
a { text-decoration: none; color: inherit; }
button { border: none; background: none; cursor: pointer; font: inherit; color: inherit; }

/* Video BG */
.bg-video-wrap { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.bg-video { position: absolute; inset: -5%; width: 110%; height: 110%; object-fit: cover; opacity: 0.08; }
.bg-video-wrap::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 0%, transparent 0%, var(--bg) 70%); }

/* Sidebar */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w);
  background: rgba(9, 9, 11, 0.9); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 50;
}
.sidebar-header { display: flex; align-items: center; gap: 10px; padding: 20px 20px; border-bottom: 1px solid var(--border); }
.sidebar-logo { width: 28px; height: 28px; border-radius: 6px; }
.sidebar-brand { font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  font-size: 14px; font-weight: 500; color: var(--text-secondary); transition: all 0.15s;
}
.sidebar-link:hover { background: var(--surface-hover); color: var(--text); }
.sidebar-link.active { background: var(--purple); color: #fff; }
.sidebar-link i { width: 18px; text-align: center; font-size: 14px; }
.sidebar-footer { padding: 12px 8px; border-top: 1px solid var(--border); }
.sidebar-x { justify-content: center; }

/* Main */
.main-content { flex: 1; margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; position: relative; z-index: 1; }

/* Topbar */
.topbar {
  position: sticky; top: 0; height: var(--topbar-h);
  background: rgba(9, 9, 11, 0.7); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 16px; z-index: 40;
}
.menu-toggle { display: none; width: 36px; height: 36px; border-radius: 8px; color: var(--text-secondary); font-size: 16px; }
.menu-toggle:hover { background: var(--surface-hover); }
.topbar-title { flex: 1; }
.topbar-title h1 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.wallet-balance { font-size: 13px; font-weight: 500; color: var(--green); }
.wallet-btn {
  display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 8px;
  background: var(--purple); color: #fff; font-size: 13px; font-weight: 600;
  transition: background 0.15s, transform 0.15s;
}
.wallet-btn:hover { background: var(--purple-hover); transform: translateY(-1px); }
.wallet-btn.connected { background: var(--green-dim); color: var(--green); }
.wallet-btn i { font-size: 13px; }

/* Sections */
.content-section { display: none; padding: 24px; flex: 1; }
.content-section.active { display: block; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.section-header h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.section-desc { font-size: 14px; color: var(--text-secondary); margin-bottom: 20px; line-height: 1.6; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; display: flex; align-items: center; gap: 16px;
  transition: border-color 0.15s;
}
.stat-card:hover { border-color: rgba(255,255,255,0.1); }
.stat-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0;
}
.stat-icon.green { background: var(--green-dim); color: var(--green); }
.stat-icon.purple { background: rgba(153, 69, 255, 0.12); color: var(--purple); }
.stat-icon.yellow { background: var(--yellow-dim); color: var(--yellow); }
.stat-icon.red { background: var(--red-dim); color: var(--red); }
.stat-body { display: flex; flex-direction: column; gap: 2px; }
.stat-body .stat-value { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.stat-body .stat-label { font-size: 12px; color: var(--text-secondary); }

/* Quick Start */
.quick-steps { display: flex; gap: 16px; padding: 20px 24px; }
.qstep { flex: 1; display: flex; align-items: flex-start; gap: 12px; }
.qstep-num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--purple); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.qstep-text strong { display: block; font-size: 14px; margin-bottom: 2px; }
.qstep-text span { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

/* Cards */
.card {
  background: var(--surface); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 12px; margin-bottom: 16px; overflow: hidden;
}
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-header h2 { font-size: 14px; font-weight: 600; }

/* Activity */
.activity-list { max-height: 360px; overflow-y: auto; }
.activity-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 20px;
  border-bottom: 1px solid var(--border); transition: background 0.1s;
}
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--surface-hover); }
.activity-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0;
}
.activity-icon.bond { background: var(--green-dim); color: var(--green); }
.activity-icon.slash { background: var(--red-dim); color: var(--red); }
.activity-icon.constraint { background: var(--blue-dim); color: var(--blue); }
.activity-info { flex: 1; min-width: 0; }
.activity-title { font-size: 13px; font-weight: 500; }
.activity-desc { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.activity-amount { font-size: 13px; font-weight: 600; white-space: nowrap; }
.activity-amount.positive { color: var(--green); }
.activity-amount.negative { color: var(--red); }

/* Agents Grid */
.agents-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.agent-card {
  background: var(--surface); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 12px; padding: 20px;
  transition: border-color 0.15s, transform 0.15s;
}
.agent-card:hover { border-color: rgba(255,255,255,0.1); transform: translateY(-1px); }
.agent-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.agent-card-avatar {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  display: flex; align-items: center; justify-content: center; font-size: 16px; color: #fff;
}
.agent-card-info h3 { font-size: 15px; font-weight: 600; }
.agent-card-info p { font-size: 12px; color: var(--text-muted); font-family: monospace; }
.agent-card-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.agent-stat .value { font-size: 15px; font-weight: 600; }
.agent-stat .label { font-size: 11px; color: var(--text-muted); }

/* Bonds */
.bonds-list { display: flex; flex-direction: column; gap: 8px; }
.bond-card {
  background: var(--surface); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px;
  display: flex; align-items: center; gap: 16px; transition: border-color 0.15s;
}
.bond-card:hover { border-color: rgba(255,255,255,0.1); }
.bond-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--green-dim); color: var(--green); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.bond-info { flex: 1; min-width: 0; }
.bond-info h3 { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.bond-info p { font-size: 12px; color: var(--text-secondary); }
.bond-amount { text-align: right; }
.bond-amount .value { font-size: 16px; font-weight: 700; color: var(--green); }
.bond-amount .label { font-size: 11px; color: var(--text-muted); }
.bond-actions { display: flex; gap: 8px; }

/* Constraints */
.constraints-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.constraint-card {
  background: var(--surface); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px;
}
.constraint-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.constraint-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.constraint-icon.spend { background: var(--yellow-dim); color: var(--yellow); }
.constraint-icon.program { background: var(--blue-dim); color: var(--blue); }
.constraint-icon.timelock { background: var(--green-dim); color: var(--green); }
.constraint-icon.velocity { background: var(--red-dim); color: var(--red); }
.constraint-header h3 { font-size: 14px; font-weight: 600; flex: 1; }
.constraint-row { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; }
.constraint-row .label { color: var(--text-secondary); }
.constraint-row .value { font-weight: 500; }
.constraint-status { display: flex; align-items: center; gap: 6px; padding-top: 10px; margin-top: 10px; border-top: 1px solid var(--border); font-size: 12px; }
.constraint-status .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

/* Buttons */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px;
  background: var(--purple); color: #fff;
  font-size: 13px; font-weight: 600;
  transition: background 0.15s, transform 0.15s;
}
.btn-primary:hover { background: var(--purple-hover); transform: translateY(-1px); }
.btn-ghost { font-size: 13px; color: var(--text-secondary); transition: color 0.15s; }
.btn-ghost:hover { color: var(--text); }  .btn-outline { border: 1px solid var(--border); padding: 6px 12px; border-radius: 6px; font-size: 12px; color: var(--text-secondary); transition: all 0.15s; }
  .btn-outline:hover { border-color: var(--text-muted); color: var(--text); }
  .btn-slash { border: 1px solid var(--red); padding: 6px 12px; border-radius: 6px; font-size: 12px; color: var(--red); background: transparent; cursor: pointer; transition: all 0.15s; margin-left: 6px; }
  .btn-slash:hover { background: var(--red-dim); color: var(--red); }
  .btn-danger { background: var(--red); color: #fff; border: none; padding: 10px 24px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.15s; }
  .btn-danger:hover { background: #dc2626; }
.btn-danger { background: var(--red-dim); color: var(--red); padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; transition: background 0.15s; }
.btn-danger:hover { background: rgba(239, 68, 68, 0.2); }

/* Filters */
.filter-select {
  background: var(--surface-solid); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 13px; color: var(--text); font-family: var(--font); cursor: pointer;
}
.filter-select:focus { outline: none; border-color: var(--purple); }

/* Activity Full */
.activity-full-list { display: flex; flex-direction: column; gap: 8px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; z-index: 200; padding: 24px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: rgba(15, 15, 18, 0.95); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border); border-radius: 14px;
  width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--text-muted); }
.modal-close:hover { background: var(--surface-hover); color: var(--text); }
.modal-body { padding: 20px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; background: var(--surface-solid); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; font-size: 14px; color: var(--text); font-family: var(--font);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--purple); }
.form-group .hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 14px 20px; background: rgba(15, 15, 18, 0.95); border: 1px solid var(--border);
  border-radius: 12px; font-size: 13px; font-weight: 500; color: var(--text);
  transform: translateY(120%); opacity: 0; transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 300; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: flex; align-items: center; gap: 10px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: rgba(34, 197, 94, 0.3); }
.toast.error { border-color: rgba(239, 68, 68, 0.3); }

/* TX Status */
.tx-status {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; border-radius: 10px;
  font-size: 13px; font-weight: 500; z-index: 300;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.tx-status.pending { background: rgba(153, 69, 255, 0.15); border: 1px solid rgba(153, 69, 255, 0.3); color: #c084fc; }
.tx-status.success { background: rgba(34, 197, 94, 0.15); border: 1px solid rgba(34, 197, 94, 0.3); color: var(--green); }
.tx-status.error { background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.3); color: var(--red); }

/* Status Badge */
.status-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; text-transform: capitalize;
}
.status-badge.active { background: var(--green-dim); color: var(--green); }
.status-badge.pending { background: var(--yellow-dim); color: var(--yellow); }
.status-badge.slashed { background: var(--red-dim); color: var(--red); }
.status-badge.suspended { background: rgba(234,179,8,0.12); color: var(--yellow); }

/* Empty State */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 24px; text-align: center; color: var(--text-secondary);
  width: 100%;
}
.empty-state .empty-icon {
  width: 56px; height: 56px; border-radius: 14px;
  background: rgba(153, 69, 255, 0.08); border: 1px solid rgba(153, 69, 255, 0.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: var(--purple); margin-bottom: 16px;
}
.empty-state h3 { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 13px; line-height: 1.5; max-width: 320px; }
.agents-grid:has(.empty-state),
.bonds-list:has(.empty-state),
.constraints-grid:has(.empty-state),
.activity-full-list:has(.empty-state) {
  display: flex; align-items: center; justify-content: center;
  min-height: 300px;
}

/* Loading */
.loading-spinner {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-secondary);
}
.loading-spinner::before {
  content: ""; width: 16px; height: 16px; border: 2px solid var(--border);
  border-top-color: var(--purple); border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, rgba(255,255,255,0.04) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Section fade in */
.content-section.active { animation: sectionIn 0.3s ease-out; }
@keyframes sectionIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Stat card hover */
.stat-card { transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); }

/* Agent card hover */
.agent-card { transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s; }
.agent-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); }

/* Bond card hover */
.bond-card { transition: border-color 0.2s, transform 0.2s; }
.bond-card:hover { transform: translateY(-1px); }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: 280px; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 45; display: none; }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .menu-toggle { display: flex; }
  .content-section { padding: 16px; }
  .section-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .section-header h2 { font-size: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 14px; gap: 10px; }
  .stat-icon { width: 36px; height: 36px; font-size: 14px; }
  .stat-body .stat-value { font-size: 18px; }
  .wallet-btn span { display: none; }
  .wallet-btn { padding: 8px 12px; }
  .wallet-balance { font-size: 11px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-title h1 { font-size: 14px; }
  .agents-grid, .constraints-grid { grid-template-columns: 1fr; }
  .agent-card { padding: 16px; }
  .agent-card-header { margin-bottom: 12px; }
  .agent-card-stats { gap: 8px; }
  .quick-steps { flex-direction: column; gap: 12px; padding: 16px; }
  .qstep { gap: 10px; }
  .qstep-text strong { font-size: 13px; }
  .qstep-text span { font-size: 12px; }
  .bond-card { flex-direction: column; align-items: flex-start; gap: 12px; }
  .bond-amount { text-align: left; }
  .constraint-card { padding: 14px; }
  .modal { margin: 16px; max-width: none; }
  .modal-body { padding: 16px; }
  .form-group input, .form-group select { font-size: 16px; padding: 12px 14px; }
  .toast { left: 16px; right: 16px; bottom: 16px; }
  .activity-item { padding: 10px 16px; }
  .activity-title { font-size: 12px; }
  .activity-desc { font-size: 11px; }
  .activity-amount { font-size: 12px; }
  .card-header { padding: 12px 16px; }
  .empty-state { padding: 40px 16px; }
  .empty-state h3 { font-size: 14px; }
  .empty-state p { font-size: 12px; }
}

/* Small phones */
@media (max-width: 380px) {
  .stat-card { padding: 12px; gap: 8px; }
  .stat-icon { width: 32px; height: 32px; font-size: 12px; }
  .stat-body .stat-value { font-size: 16px; }
  .agent-card { padding: 12px; }
  .bond-card { padding: 12px; }
}
