/* ============================================
   Clawnads Design System
   Tokens & components: see DESIGN.md
   ============================================ */

/* ===== CSS Custom Properties (Design Tokens) ===== */
:root {
  /* Background colors */
  --color-bg-deep: #09090b;
  --color-bg-panel: #0a0a0a;
  --color-bg-card: #18181b;
  --color-bg-elevated: #27272a;
  --color-bg-hover: #3f3f46;

  /* Text colors */
  --color-text-primary: #fafafa;
  --color-text-secondary: #a1a1aa;
  --color-text-tertiary: #71717a;
  --color-text-muted: #52525b;

  /* Border colors */
  --color-border: #1a1a1a;
  --color-border-subtle: #27272a;

  /* Accent colors */
  --color-accent: #7c5cff;
  --color-accent-hover: #9b7dff;
  --color-accent-active: #a78bfa;
  --color-success: #22c55e;
  --color-success-dark: #16a34a;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --color-info: #3b82f6;
  --color-orange: #f97316;
  --color-purple: #a855f7;
  --color-swap: #a855f7;

  /* Fonts */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;

  /* Typography scale */
  --text-xs: 0.6875rem;   /* 11px */
  --text-sm: 0.75rem;     /* 12px */
  --text-base: 0.8125rem; /* 13px */
  --text-md: 0.875rem;    /* 14px */
  --text-lg: 1rem;        /* 16px */
  --text-xl: 1.125rem;    /* 18px */
  --text-2xl: 1.25rem;    /* 20px */
  --text-3xl: 1.5rem;     /* 24px */
  --text-4xl: 2rem;       /* 32px */

  /* Line heights */
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.65;

  /* Spacing scale */
  --space-1: 2px;
  --space-2: 4px;
  --space-3: 6px;
  --space-4: 8px;
  --space-5: 10px;
  --space-6: 12px;
  --space-8: 16px;
  --space-10: 20px;
  --space-12: 24px;
  --space-16: 32px;
  --space-20: 40px;
  --space-24: 48px;

  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-2xl: 16px;
  --radius-pill: 9999px;

  /* Shadows */
  --shadow-subtle: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-elevated: 0 8px 32px rgba(0, 0, 0, 0.6);

  /* Z-index scale */
  --z-base: 1;
  --z-dropdown: 50;
  --z-sticky: 99;
  --z-header: 100;
  --z-overlay: 200;
  --z-drawer: 201;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;

  /* Layout */
  --drawer-width: 420px;
}

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

/* ===== Scrollbar Styling ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* ===== Focus Visible ===== */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ===== Base ===== */
body {
  font-family: var(--font-sans);
  background: var(--color-bg-deep);
  color: var(--color-text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Header ===== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-10) var(--space-16);
  background: var(--color-bg-deep);
  position: sticky;
  top: 0;
  z-index: var(--z-header);
}

.logo {
  display: flex;
  align-items: center;
}

.logo img {
  height: 28px;
  width: auto;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  font-size: var(--text-md);
  color: var(--color-text-tertiary);
}

.header-right a {
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.header-right a:hover {
  color: var(--color-text-primary);
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: var(--space-6);
  padding: var(--space-6) var(--space-16);
  background: var(--color-bg-deep);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 65px;
  z-index: var(--z-sticky);
}

.tab {
  padding: var(--space-5) var(--space-10);
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--color-text-tertiary);
  background: transparent;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab:hover {
  color: var(--color-text-secondary);
  background: rgba(39, 39, 42, 0.5);
}

.tab.active {
  color: var(--color-text-primary);
  background: var(--color-bg-elevated);
  border-color: var(--color-bg-elevated);
}

/* ===== Main Content ===== */
.container {
  position: relative;
  max-width: 100%;
  margin: 0 auto;
  padding: var(--space-12) var(--space-16) var(--space-16);
  flex: 1;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

#agents-tab {
  margin: 0 calc(-1 * var(--space-16));
  width: calc(100% + var(--space-16) * 2);
}

/* ===== Cards ===== */
.card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin-bottom: var(--space-16);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-10);
}

.card-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
}

/* ===== Code Blocks ===== */
.code-block {
  background: var(--color-bg-card);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-8);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  color: var(--color-text-secondary);
  overflow-x: auto;
  position: relative;
  line-height: 1.6;
}

.copy-btn {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  background: var(--color-bg-elevated);
  color: var(--color-text-secondary);
  border: none;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.copy-btn:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}

.copy-btn.copied {
  background: var(--color-success);
  color: var(--color-bg-deep);
}

/* ===== Agent Table ===== */
.agent-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.agent-table thead {
  border-bottom: 1px solid var(--color-border);
}

.agent-table th {
  text-align: left;
  padding: var(--space-8) var(--space-12);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.agent-table th:first-child {
  width: 30%;
  padding-left: var(--space-16);
}

.agent-table th:last-child {
  padding-right: var(--space-16);
}

.agent-table td {
  padding: var(--space-10) var(--space-12);
  border: none;
  font-size: var(--text-md);
  vertical-align: middle;
}

.agent-table td:first-child {
  padding-left: var(--space-16);
}

.agent-table td:last-child {
  padding-right: var(--space-16);
}

.agent-table tr {
  cursor: pointer;
  transition: background var(--transition-fast);
}

.agent-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.agent-table tbody tr.selected {
  background: rgba(34, 197, 94, 0.08);
}

.agent-name-cell {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.agent-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--color-success), var(--color-success-dark));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-bg-deep);
  flex-shrink: 0;
}

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

.agent-desc {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  margin-top: var(--space-1);
}

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0;
  border-radius: 0;
  font-size: var(--text-base);
  font-weight: 500;
}

.badge-green {
  background: transparent;
  color: var(--color-success);
}

.badge-blue {
  background: transparent;
  color: var(--color-info);
}

.badge-red {
  background: transparent;
  color: var(--color-error);
}

/* ===== Skeleton Loading ===== */
.skeleton {
  background: linear-gradient(90deg, var(--color-bg-elevated) 25%, var(--color-bg-hover) 50%, var(--color-bg-elevated) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.skeleton-text {
  height: 14px;
  margin-bottom: var(--space-3);
}

.skeleton-text-sm {
  height: 10px;
  width: 60%;
}

.skeleton-badge {
  height: 20px;
  width: 70px;
  border-radius: var(--radius-pill);
}

.skeleton-address {
  height: 14px;
  width: 100px;
}

/* ===== Copyable Address ===== */
.address-cell {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.address-copy-btn {
  background: none;
  border: none;
  color: var(--color-text-tertiary);
  cursor: pointer;
  padding: var(--space-1);
  font-size: var(--text-xs);
  transition: color var(--transition-fast);
  display: flex;
  align-items: center;
}

.address-copy-btn:hover {
  color: var(--color-success);
}

.address-copy-btn.copied {
  color: var(--color-success);
}

/* ===== Stats ===== */
.stat-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-5) 0;
  border-bottom: none;
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-label {
  color: var(--color-text-tertiary);
  font-size: var(--text-md);
}

.stat-value {
  color: var(--color-text-primary);
  font-size: var(--text-md);
  font-weight: 500;
}

.stat-value a {
  color: var(--color-success);
  text-decoration: none;
}

.stat-value a:hover {
  text-decoration: underline;
}

.stat-value.mono {
  font-family: var(--font-mono);
  font-size: var(--text-base);
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: var(--space-24) var(--space-12);
  color: var(--color-text-tertiary);
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-6);
  opacity: 0.5;
}

/* ===== Loading ===== */
.loading {
  text-align: center;
  padding: var(--space-12);
  color: var(--color-text-tertiary);
}

/* ===== Error ===== */
.error {
  background: transparent;
  border: none;
  color: var(--color-error);
  padding: var(--space-6) 0;
  border-radius: 0;
  font-size: var(--text-md);
}

/* ===== Section Headers ===== */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-8);
}

.section-title {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text-primary);
}

.section-count {
  font-size: var(--text-md);
  color: var(--color-text-tertiary);
}

/* ===== Buttons ===== */
.btn {
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border-subtle);
  padding: var(--space-4) var(--space-8);
  border-radius: var(--radius-pill);
  font-size: var(--text-base);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn:hover {
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
}

.btn-primary {
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
  border-color: var(--color-bg-elevated);
}

.btn-primary:hover {
  background: var(--color-bg-hover);
  border-color: var(--color-bg-hover);
}

/* ===== Grid Layout ===== */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8);
}

@media (max-width: 768px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

/* ===== Utilities ===== */
.highlight {
  color: var(--color-success);
}

.divider {
  height: 1px;
  background: var(--color-border);
  margin: 0;
}

/* ===== Footer ===== */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-6) var(--space-16);
  background: var(--color-bg-deep);
  border-top: 1px solid var(--color-border);
  z-index: var(--z-header);
}

.footer-left {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  font-size: var(--text-base);
  color: var(--color-text-muted);
}

.footer-brand {
  font-weight: 600;
  color: var(--color-text-tertiary);
}

.footer-separator {
  color: var(--color-bg-hover);
}

.footer-network {
  color: var(--color-text-muted);
}

.footer-right {
  font-size: var(--text-base);
}

.footer-right a {
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-right a:hover {
  color: var(--color-text-secondary);
}

.footer-profile {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.footer-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

/* ===== Right Drawer ===== */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
  z-index: var(--z-overlay);
}

.drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--drawer-width);
  max-width: 100%;
  height: 100vh;
  background: var(--color-bg-panel);
  border-left: 1px solid var(--color-border);
  transform: translateX(100%);
  transition: transform var(--transition-normal);
  z-index: var(--z-drawer);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-elevated);
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-10);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  background: var(--color-bg-panel);
  z-index: 10;
}

.drawer-close {
  background: none;
  border: none;
  color: var(--color-text-tertiary);
  cursor: pointer;
  padding: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}

.drawer-close svg {
  width: 20px;
  height: 20px;
}

.drawer-close:hover {
  color: var(--color-text-primary);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  padding-bottom: 70px;
}

/* ===== Drawer Tabs (bottom nav) ===== */
.drawer-tabs {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 0;
  padding: 0;
  background: var(--color-bg-deep);
  border-top: 1px solid var(--color-border);
}

.drawer-tab {
  flex: 1;
  padding: var(--space-6) var(--space-10);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-tertiary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.drawer-tab:hover {
  color: var(--color-text-secondary);
}

.drawer-tab.active {
  color: var(--color-accent-active);
}

.drawer-tab-icon {
  width: 18px;
  height: 18px;
}

.drawer-tab-content {
  display: none;
}

.drawer-tab-content.active {
  display: block;
}

/* ===== Wallet Balance Header ===== */
.balance-header {
  background: var(--color-bg-panel);
  padding: var(--space-12) var(--space-10);
  text-align: center;
  border-bottom: none;
}

.balance-usd-primary {
  font-size: var(--text-4xl);
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.balance-tokens {
  font-size: 0.9375rem;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-8);
}

.wallet-address-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  font-size: var(--text-base);
  color: var(--color-text-tertiary);
  font-family: monospace;
}

.wallet-address-row button {
  background: none;
  border: none;
  color: var(--color-text-tertiary);
  cursor: pointer;
  padding: var(--space-2);
  font-size: var(--text-md);
  transition: color var(--transition-fast);
  display: flex;
  align-items: center;
}

.wallet-address-row button:hover {
  color: var(--color-text-primary);
}

/* ===== Wallet Sub-tabs ===== */
.wallet-subtabs {
  display: flex;
  gap: var(--space-6);
  padding: var(--space-8) var(--space-10);
  background: var(--color-bg-panel);
}

.wallet-subtab {
  background: transparent;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  color: var(--color-text-tertiary);
  padding: var(--space-5) var(--space-10);
  font-size: var(--text-md);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.wallet-subtab:hover {
  color: var(--color-text-secondary);
  background: rgba(39, 39, 42, 0.5);
}

.wallet-subtab.active {
  color: var(--color-text-primary);
  background: var(--color-bg-elevated);
  border-color: var(--color-bg-elevated);
}

.wallet-subtab-content {
  display: none;
}

.wallet-subtab-content.active {
  display: block;
}

/* ===== Icon Button ===== */
.icon-btn {
  background: none;
  border: none;
  color: var(--color-text-tertiary);
  cursor: pointer;
  padding: var(--space-2);
  font-size: var(--text-md);
  transition: color var(--transition-fast);
  display: flex;
  align-items: center;
}

.icon-btn svg {
  width: 14px;
  height: 14px;
}

.icon-btn:hover {
  color: var(--color-text-primary);
}

.icon-btn.copied {
  color: var(--color-success);
}

/* ===== Activity List ===== */
.activity-section {
  padding: var(--space-8) 0;
}

.activity-section-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 var(--space-10) var(--space-6);
}

.activity-item {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-8) var(--space-10);
  cursor: pointer;
  transition: background var(--transition-fast);
  flex-wrap: wrap;
}

.activity-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.activity-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.activity-icon svg {
  width: 18px;
  height: 18px;
}

.activity-icon.send {
  background: transparent;
  color: var(--color-info);
}

.activity-icon.receive {
  background: transparent;
  color: var(--color-success);
}

.activity-icon.contract {
  background: transparent;
  color: var(--color-orange);
}

.activity-icon.swap {
  background: transparent;
  color: var(--color-swap);
}

.activity-details {
  flex: 1;
  min-width: 0;
}

.activity-type {
  font-weight: 600;
  color: var(--color-text-primary);
  font-size: 0.9375rem;
  margin-bottom: var(--space-1);
}

.activity-time {
  font-size: 0.65rem;
  color: var(--color-text-tertiary);
  font-weight: 400;
  margin-left: var(--space-2);
  vertical-align: baseline;
}

.activity-meta {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.activity-amount {
  text-align: right;
  flex-shrink: 0;
}

.activity-amount-value {
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: var(--space-1);
}

.activity-amount-value.negative {
  color: var(--color-text-primary);
}

.activity-amount-value.positive {
  color: var(--color-success);
}

.activity-amount-usd {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
}

.activity-amount-value sub {
  font-size: 0.7em;
  vertical-align: baseline;
  position: relative;
  bottom: -0.15em;
  color: inherit;
  opacity: 0.7;
}

.activity-token-img {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  vertical-align: middle;
  margin-left: var(--space-3);
}

.activity-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: var(--space-4);
  flex-shrink: 0;
}

.activity-actions .icon-btn {
  font-size: var(--text-sm);
  padding: var(--space-1);
}

/* ===== Trade Reasoning (inline) ===== */
.reasoning-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  padding: var(--space-2) 0 0 44px;
  width: 100%;
  user-select: none;
}

.reasoning-toggle:hover span {
  opacity: 0.8;
}

.toggle-icon.rotated {
  transform: rotate(180deg);
}

.reasoning-panel {
  width: 100%;
  padding: 0 0 0 44px;
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-normal), padding var(--transition-normal);
}

.reasoning-panel.expanded {
  max-height: 200px;
  padding: var(--space-4) 0 var(--space-2) 44px;
}

.reasoning-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: var(--space-1) var(--space-4);
  border-radius: var(--radius-pill);
  text-transform: capitalize;
}

.reasoning-confidence {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.confidence-bar {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
  max-width: 120px;
}

.confidence-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ===== Portfolio Section ===== */
.portfolio-section {
  padding: var(--space-8) 0;
}

.portfolio-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px var(--space-10);
  border-bottom: none;
  transition: background var(--transition-fast);
}

.portfolio-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.portfolio-token {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.portfolio-token-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.portfolio-token-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-text-primary);
}

.portfolio-token-name {
  font-weight: 600;
  color: var(--color-text-primary);
}

.portfolio-balance {
  text-align: right;
}

.portfolio-balance-amount {
  font-weight: 600;
  color: var(--color-text-primary);
}

.portfolio-balance-amount sub {
  font-size: 0.7em;
  vertical-align: baseline;
  position: relative;
  bottom: -0.15em;
  color: inherit;
  opacity: 0.7;
}

.portfolio-balance-usd {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
}

.portfolio-item.zero-balance {
  opacity: 0.5;
}

.portfolio-balance-amount.dimmed {
  color: var(--color-text-muted);
}

/* ===== Profile Section in Drawer ===== */
.drawer-profile {
  padding: var(--space-8) var(--space-10);
  border-bottom: none;
}

.drawer-profile-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) 0;
}

.drawer-profile-label {
  font-size: var(--text-base);
  color: var(--color-text-tertiary);
}

.drawer-profile-value {
  font-size: var(--text-base);
  color: var(--color-text-primary);
  font-weight: 500;
}

.drawer-profile-value a {
  color: var(--color-success);
  text-decoration: none;
}

.drawer-profile-value a:hover {
  text-decoration: underline;
}

/* ===== Activity Empty ===== */
.activity-empty {
  text-align: center;
  padding: var(--space-20) var(--space-10);
  color: var(--color-text-tertiary);
}

/* ===== Karma Badge ===== */
.karma-display {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.karma-positive {
  color: var(--color-success);
}

.karma-negative {
  color: var(--color-error);
}

/* ===== Profile Tab Styles ===== */
.profile-section {
  padding: var(--space-10);
}

.profile-header {
  text-align: center;
  padding-bottom: var(--space-10);
  border-bottom: none;
  margin-bottom: var(--space-8);
}

.profile-avatar {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--color-success), var(--color-success-dark));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 600;
  color: var(--color-bg-deep);
  margin: 0 auto var(--space-6);
}

.profile-name {
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.profile-desc {
  font-size: var(--text-base);
  color: var(--color-text-tertiary);
  line-height: 1.4;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
  padding: var(--space-8) 0;
  border-bottom: none;
  margin-bottom: var(--space-8);
}

.profile-stat {
  text-align: center;
}

.profile-stat-value {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text-primary);
}

.profile-stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.profile-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.profile-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.profile-detail-label {
  font-size: var(--text-base);
  color: var(--color-text-tertiary);
}

.profile-detail-value {
  font-size: var(--text-base);
  color: var(--color-text-primary);
  font-weight: 500;
}

.profile-detail-value a {
  color: var(--color-success);
  text-decoration: none;
}

.profile-detail-value a:hover {
  text-decoration: underline;
}

/* ===== ERC-8004 Identity Section ===== */
.erc8004-section {
  margin-top: var(--space-8);
  padding-top: var(--space-8);
  border-top: 1px solid var(--color-border);
}

.erc8004-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.erc8004-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text-primary);
}

.erc8004-badge {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-4);
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.erc8004-badge:hover {
  background: var(--color-accent);
  color: var(--color-bg-deep);
}

.erc8004-id-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.erc8004-id-label {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--color-text-primary);
}

.erc8004-id-label.erc8004-pending {
  color: var(--color-text-tertiary);
  font-style: italic;
  font-weight: 400;
}

.erc8004-nft-link {
  font-size: var(--text-sm);
  color: var(--color-accent);
  text-decoration: none;
}

.erc8004-nft-link:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

.erc8004-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.erc8004-detail {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.erc8004-detail-full {
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
}

.erc8004-detail-label {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
}

.erc8004-detail-value {
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  font-weight: 500;
}

.erc8004-detail-value a {
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-decoration: none;
}

.erc8004-detail-value a:hover {
  color: var(--color-accent);
}

.erc8004-detail-desc {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
}

.erc8004-trust-tags,
.erc8004-services {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.erc8004-tag {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  background: var(--color-bg-elevated);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-3);
}

/* ================================
   VISUALIZER STYLES
   ================================ */

#home-tab {
  margin: calc(-1 * var(--space-12)) calc(-1 * var(--space-16)) calc(-1 * var(--space-16));
  padding: 0;
}

/* Two-panel layout */
.visualizer-layout {
  display: flex;
  width: 100vw;
  height: calc(100vh - 170px);
  max-height: calc(100vh - 170px);
  background: var(--color-bg-deep);
}

/* Left panel: Sankey diagram */
.viz-sankey-panel {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header with stats and time selector */
.viz-sankey-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: var(--space-10) var(--space-16);
  z-index: 10;
}

/* Stats Row - Birdeye style */
.viz-stats-row {
  display: flex;
  gap: var(--space-16);
}

.viz-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.viz-stat-main {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}

.viz-stat-value {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text-primary);
  font-family: var(--font-mono);
}

.viz-stat-change {
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
}

.viz-stat-change.positive {
  color: var(--color-success);
  background: rgba(34, 197, 94, 0.1);
}

.viz-stat-change.negative {
  color: var(--color-error);
  background: rgba(239, 68, 68, 0.1);
}

.viz-stat-change.neutral {
  color: var(--color-text-tertiary);
  background: rgba(113, 113, 122, 0.1);
}

.viz-stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Time period selector */
.viz-time-selector {
  display: flex;
  gap: var(--space-2);
  background: rgba(39, 39, 42, 0.5);
  padding: var(--space-2);
  border-radius: var(--radius-lg);
}

.viz-time-btn {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-tertiary);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.viz-time-btn:hover {
  color: var(--color-text-secondary);
}

.viz-time-btn.active {
  color: var(--color-text-primary);
  background: var(--color-bg-elevated);
}

/* Right panel: Trades feed */
.viz-trades-panel {
  width: 280px;
  border-left: 1px solid var(--color-border);
  background: var(--color-bg-deep);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.viz-trades-header {
  padding: var(--space-8) var(--space-10);
  font-weight: 600;
  font-size: var(--text-md);
  color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-border);
}

.viz-trades-list {
  flex: 1;
  overflow-y: auto;
}

.viz-trades-empty {
  padding: var(--space-16) var(--space-8);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* Canvas */
.viz-canvas-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
}

#trade-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Agent Legend */
.viz-agent-legend {
  padding: var(--space-6) var(--space-10);
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  background: var(--color-bg-deep);
  border-top: 1px solid var(--color-border);
}

.viz-agent-chip {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-6);
  background: rgba(39, 39, 42, 0.8);
  border: 1px solid var(--color-bg-hover);
  border-radius: 20px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.viz-agent-chip:hover {
  background: rgba(63, 63, 70, 0.9);
  border-color: var(--color-text-muted);
}

.viz-agent-chip.active {
  border-color: var(--color-success);
  background: rgba(34, 197, 94, 0.1);
}

.viz-agent-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--color-bg-deep);
}

.viz-agent-name {
  font-size: var(--text-base);
  color: var(--color-text-primary);
}

.viz-agent-trades {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
}

/* Trade Feed Overlay */
.viz-trade-feed {
  position: absolute;
  top: var(--space-10);
  right: var(--space-10);
  width: 300px;
  max-height: calc(100% - 40px);
  background: rgba(24, 24, 27, 0.95);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.viz-feed-header {
  padding: var(--space-6) var(--space-8);
  border-bottom: 1px solid var(--color-border-subtle);
  font-weight: 600;
  font-size: var(--text-md);
  color: var(--color-text-primary);
}

.viz-feed-list {
  flex: 1;
  overflow-y: auto;
  max-height: 400px;
}

.viz-feed-empty {
  padding: var(--space-20) var(--space-8);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-md);
}

.viz-trade-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-8);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.viz-trade-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.viz-trade-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.viz-trade-agent {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-primary);
}

.viz-trade-time {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.viz-trade-body {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.viz-trade-token-img {
  width: 18px;
  height: 18px;
  border-radius: 50%;
}

.viz-trade-label {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

.viz-trade-arrow {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  margin: 0 var(--space-1);
}

.viz-trade-time {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
}

.viz-trade-amount {
  text-align: right;
  flex-shrink: 0;
}

.viz-trade-amount-value {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--color-text-primary);
}

/* Token gradient classes */
.token-mon { background: linear-gradient(135deg, #22c55e, #16a34a); }
.token-wmon { background: linear-gradient(135deg, #22c55e, #16a34a); }
.token-usdc { background: linear-gradient(135deg, #2775ca, #1e5fa8); }
.token-usdt { background: linear-gradient(135deg, #26a17b, #1e8062); }
.token-weth { background: linear-gradient(135deg, #627eea, #4a63c4); }
.token-wbtc { background: linear-gradient(135deg, #f7931a, #d47a10); }

/* Reasoning indicator */
.viz-trade-reasoning {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-swap);
  margin-left: var(--space-4);
}

/* ===== Reasoning Tab (prose journal) ===== */
.reasoning-journal {
  overflow-y: auto;
  max-height: calc(100vh - 280px);
  padding: var(--space-8) 18px;
}

.reasoning-date-header {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: var(--space-10) 0 var(--space-6) 0;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.reasoning-date-header:first-child {
  margin-top: 0;
}

.reasoning-entry {
  margin-bottom: var(--space-8);
}

.reasoning-entry-text {
  font-size: var(--text-base);
  color: #e0e0f0;
  line-height: var(--leading-relaxed);
}

.reasoning-entry-text strong {
  font-weight: 600;
  color: var(--color-text-primary);
}

.reasoning-entry-text .context {
  color: #7c7c98;
}

.reasoning-entry-text .confidence {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.reasoning-entry-meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
  line-height: var(--leading-normal);
}

.reasoning-entry-meta .sell {
  color: var(--color-error);
}

.reasoning-entry-meta .buy {
  color: var(--color-success);
}

.reasoning-entry-meta a {
  color: var(--color-accent);
  text-decoration: none;
}

.reasoning-token-img {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  vertical-align: -2px;
  margin: 0 1px;
}

.reasoning-tx-link {
  font-size: 12px;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.reasoning-tx-link:hover {
  opacity: 1;
}

.reasoning-type-label {
  color: var(--color-accent);
  font-style: italic;
  opacity: 0.7;
}

.reasoning-entry.no-reasoning {
  opacity: 0.5;
}

.reasoning-entry.no-reasoning .reasoning-entry-text {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-style: italic;
}

.reasoning-entry.no-reasoning .reasoning-entry-meta a {
  color: #555;
}

.reasoning-empty {
  padding: var(--space-16) 0;
  color: var(--color-text-muted);
  text-align: center;
}

.reasoning-empty-title {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

.reasoning-empty-desc {
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

/* Strategy badge (inline in activity) */
.strategy-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

/* ===== Row fade-in animation ===== */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.agent-table tbody tr {
  animation: fade-in 0.3s ease;
}

/* ===== Mobile Responsiveness ===== */
@media (max-width: 768px) {
  .visualizer-layout {
    flex-direction: column;
  }

  .viz-trades-panel {
    width: 100%;
    height: 40%;
    border-left: none;
    border-top: 1px solid var(--color-border);
  }

  .viz-sankey-panel {
    height: 60%;
  }

  .viz-sankey-header {
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-6);
  }

  .viz-stats-row {
    gap: var(--space-8);
  }

  .viz-stat-value {
    font-size: var(--text-md);
  }

  .viz-stat-change {
    font-size: 10px;
    padding: 1px 4px;
  }

  .viz-agent-legend {
    display: none;
  }
}
