/* ============================================================
   ChainVigil Dashboard V3 — "Guardian Cockpit" Design System
   ============================================================ */

/* --- CSS Variables (from design brief) --- */
:root {
  /* Backgrounds */
  --bg:          #06060c;
  --surface:     rgba(18, 18, 28, 0.7);
  --surface2:    rgba(26, 26, 40, 0.5);

  /* Borders */
  --border:      rgba(255, 255, 255, 0.06);
  --border2:     rgba(255, 255, 255, 0.1);

  /* Text */
  --text:        #e8e8f0;
  --text2:       rgba(255, 255, 255, 0.4);

  /* Accents */
  --cyan:        #00f0ff;
  --green:       #00ff88;
  --red:         #ff4455;
  --yellow:      #ffaa00;
  --purple:      #8b5cf6;
  --magenta:     #ff00aa;

  /* Accent backgrounds (dimmed) */
  --cyan-dim:    rgba(0, 240, 255, 0.15);
  --green-dim:   rgba(0, 255, 136, 0.12);
  --red-dim:     rgba(255, 68, 85, 0.12);
  --yellow-dim:  rgba(255, 170, 0, 0.12);

  /* Glass effect */
  --glass:       rgba(255, 255, 255, 0.03);
  --glass2:      rgba(255, 255, 255, 0.06);

  /* Typography */
  --font-body:   -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  --font-mono:   'SF Mono', 'Fira Code', 'Consolas', monospace;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* Border radius */
  --radius:      14px;
  --radius-sm:   8px;
  --radius-pill: 999px;
}

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

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Subtle background gradient */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(0, 240, 255, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(255, 0, 170, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Animations --- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.8); }
}

@keyframes borderGlow {
  0%, 100% { opacity: 0.3; }
  50%      { opacity: 0.8; }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

/* --- Typography --- */
.text-hero {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.text-score {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.text-body {
  font-size: 14px;
  font-weight: 400;
}

.text-meta {
  font-size: 12px;
  font-weight: 400;
  color: var(--text2);
}

.text-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text2);
}

.text-mono {
  font-family: var(--font-mono);
  font-weight: 700;
}

.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-cyan   { color: var(--cyan); }
.text-purple { color: var(--purple); }
.text-muted  { color: var(--text2); }

/* --- Glassmorphism Panel --- */
.panel {
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  animation: fadeUp 0.4s ease-out both;
  box-shadow: 
    0 4px 24px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* Gradient top border */
.panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--magenta), transparent);
  opacity: 0.4;
  z-index: 1;
}

.panel:hover {
  border-color: var(--border2);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 0 1px rgba(0, 240, 255, 0.03);
}

.panel-header {
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.panel-body {
  padding: 0 var(--sp-4) var(--sp-4);
}

.panel-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text2);
}

/* --- Badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  backdrop-filter: blur(8px);
}

.badge-cyan   { background: var(--cyan-dim); color: var(--cyan); border: 1px solid rgba(0, 240, 255, 0.2); }
.badge-green  { background: var(--green-dim); color: var(--green); border: 1px solid rgba(0, 255, 136, 0.2); }
.badge-red    { background: var(--red-dim); color: var(--red); border: 1px solid rgba(255, 68, 85, 0.2); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(255, 170, 0, 0.2); }
.badge-purple { background: rgba(139, 92, 246, 0.15); color: var(--purple); border: 1px solid rgba(139, 92, 246, 0.2); }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--glass2);
  border-color: var(--border2);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.1);
}

.btn-primary {
  background: var(--cyan);
  color: var(--bg);
  border-color: var(--cyan);
  font-weight: 600;
}

.btn-primary:hover {
  background: #33f5ff;
  border-color: #33f5ff;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.3);
}

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border-color: rgba(255, 68, 85, 0.2);
}

.btn-danger:hover {
  background: rgba(255, 68, 85, 0.2);
  box-shadow: 0 0 12px rgba(255, 68, 85, 0.2);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}

.btn-sm.active {
  background: var(--cyan-dim);
  color: var(--cyan);
  border-color: rgba(0, 240, 255, 0.3);
}

.btn-sm:not(.active):hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* --- Input --- */
.input {
  width: 100%;
  padding: 10px 14px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  transition: all 0.2s ease;
  outline: none;
}

.input::placeholder {
  color: var(--text2);
}

.input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(0, 240, 255, 0.1);
}

.input-mono {
  font-family: var(--font-mono);
  font-weight: 500;
}

/* --- Metric Card --- */
.metric-card {
  text-align: center;
  padding: var(--sp-4);
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
}

.metric-change {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  margin-top: var(--sp-1);
}

.metric-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text2);
  margin-top: var(--sp-1);
}

/* --- Health Ring --- */
.health-ring {
  position: relative;
  width: 80px;
  height: 80px;
}

.health-ring svg {
  transform: rotate(-90deg);
}

.health-ring-track {
  fill: none;
  stroke: var(--glass2);
  stroke-width: 6;
}

.health-ring-fill {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s ease-out;
}

.health-ring-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
}

/* --- Sparkline (placeholder for Chart.js) --- */
.sparkline {
  height: 40px;
  width: 100%;
}

/* --- Live Indicator --- */
.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse-dot 1.5s ease-in-out infinite;
  display: inline-block;
}

/* --- Skeleton Loading --- */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--glass) 25%,
    var(--glass2) 50%,
    var(--glass) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 14px;
  margin-bottom: var(--sp-2);
  border-radius: 4px;
}

.skeleton-text.short { width: 60%; }
.skeleton-text.medium { width: 80%; }

.skeleton-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.skeleton-card {
  padding: var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.skeleton-card .skeleton-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton-card .skeleton-lines {
  flex: 1;
}

/* Skeleton panel (for initial load) */
.panel.skeleton-panel .panel-body {
  min-height: 100px;
}

/* ============================================================
   LAYOUT
   ============================================================ */

/* --- Top Nav --- */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-6);
  background: rgba(6, 6, 12, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.top-nav-left {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.logo-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--cyan), var(--magenta));
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.top-nav-center {
  flex: 1;
  max-width: 400px;
  margin: 0 var(--sp-6);
}

.search-input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(0, 240, 255, 0.1);
}

.search-wrapper {
  position: relative;
}

.search-wrapper::before {
  content: '🔍';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  opacity: 0.5;
}

.top-nav-right {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* --- Alert Banner --- */
.alert-banner {
  background: var(--yellow-dim);
  border-bottom: 1px solid rgba(255, 170, 0, 0.15);
  padding: var(--sp-2) var(--sp-6);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 12px;
  animation: slideIn 0.3s ease-out;
  overflow: hidden;
}

.alert-banner-icon {
  flex-shrink: 0;
}

.alert-banner-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alert-banner-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
}

/* --- 3-Column Grid --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 260px 1fr 260px;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-6);
  max-width: 1600px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.col-left, .col-right {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.col-center {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

/* --- Mobile Tab Bar --- */
.mobile-tab-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: rgba(6, 6, 12, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding: var(--sp-2) 0;
  padding-bottom: env(safe-area-inset-bottom, var(--sp-2));
}

.mobile-tab-bar-items {
  display: flex;
  justify-content: space-around;
}

.mobile-tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--sp-1) var(--sp-3);
  background: none;
  border: none;
  color: var(--text2);
  font-size: 10px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: color 0.2s;
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
}

.mobile-tab-item.active {
  color: var(--cyan);
}

.mobile-tab-item-icon {
  font-size: 18px;
}

/* ============================================================
   AUTH SCREEN
   ============================================================ */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
  position: relative;
  z-index: 1;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: var(--sp-8);
}

.auth-logo {
  text-align: center;
  margin-bottom: var(--sp-8);
}

.auth-logo-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--cyan), var(--magenta));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto var(--sp-3);
}

.auth-logo h1 {
  font-size: 24px;
  font-weight: 700;
}

.auth-logo p {
  color: var(--text2);
  font-size: 13px;
  margin-top: var(--sp-1);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.auth-field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
}

.auth-error {
  background: var(--red-dim);
  color: var(--red);
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  font-size: 12px;
  display: none;
}

.auth-error.visible {
  display: block;
  animation: slideIn 0.3s ease-out;
}

.auth-divider {
  text-align: center;
  color: var(--text2);
  font-size: 12px;
  position: relative;
  margin: var(--sp-2) 0;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--border);
}

.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

.auth-toggle {
  text-align: center;
  font-size: 13px;
  color: var(--text2);
}

.auth-toggle a {
  color: var(--cyan);
  cursor: pointer;
  font-weight: 500;
}

.auth-footer {
  text-align: center;
  margin-top: var(--sp-6);
  font-size: 11px;
  color: var(--text2);
}

/* ============================================================
   APP SHELL COMPONENTS
   ============================================================ */

/* --- Portfolio Hero --- */
.portfolio-hero {
  padding: var(--sp-6);
  text-align: center;
}

.portfolio-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text2);
  margin-bottom: 4px;
  font-weight: 600;
}

.portfolio-total {
  font-family: var(--font-mono);
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #fff 40%, rgba(255,255,255,0.6));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.portfolio-change {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
}

.portfolio-change.text-green {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
}

.portfolio-change.text-red {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.portfolio-chart {
  height: 120px;
  margin-top: var(--sp-4);
}

/* Portfolio Donut */
.portfolio-donut-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.portfolio-donut-wrap canvas {
  width: 72px !important;
  height: 72px !important;
  flex-shrink: 0;
}

.donut-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 11px;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text2);
}

.donut-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.donut-legend-pct {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text);
}

/* --- Position Card --- */
.position-card {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  border-radius: 0;
}

.position-card:last-child {
  border-bottom: none;
}

.position-card:hover {
  background: rgba(0, 240, 255, 0.04);
  transform: translateX(2px);
  box-shadow: inset 3px 0 0 var(--cyan);
}

.position-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.12), rgba(0, 240, 255, 0.03));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  color: var(--cyan);
  border: 1px solid rgba(0, 240, 255, 0.1);
  overflow: hidden;
  position: relative;
}

.position-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
}

.position-icon-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.position-info {
  flex: 1;
  min-width: 0;
}

.position-symbol {
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.position-amount {
  font-size: 11px;
  color: var(--text2);
  font-family: var(--font-mono);
}

.position-value {
  text-align: right;
}

.position-usd {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
}

.position-pnl {
  font-family: var(--font-mono);
  font-size: 11px;
}

/* --- Position Expanded Detail --- */
.position-detail {
  padding: var(--sp-3) var(--sp-4);
  background: var(--glass);
  border-top: 1px solid var(--border);
  animation: fadeUp 0.2s ease-out;
}

.position-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2) var(--sp-4);
}

.position-detail-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-1) 0;
}

.position-detail-label {
  font-size: 11px;
  color: var(--text2);
}

.position-detail-value {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
}

/* DCA buys list */
.dca-list {
  margin-top: var(--sp-3);
  border-top: 1px solid var(--border);
  padding-top: var(--sp-2);
}

.dca-header {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text2);
  margin-bottom: var(--sp-1);
}

.dca-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-1) 0;
  font-size: 11px;
}

.dca-item-date {
  color: var(--text2);
  font-size: 10px;
}

.dca-item-amount {
  font-family: var(--font-mono);
}

.dca-item-price {
  font-family: var(--font-mono);
  color: var(--text2);
}

/* Add DCA buy inline */
.dca-add {
  margin-top: var(--sp-2);
  display: flex;
  gap: var(--sp-2);
}

.dca-add .input {
  font-size: 11px;
  padding: 6px 8px;
}

/* --- Alert Card --- */
.alert-card {
  padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-4);
  border-left: 3px solid transparent;
  transition: background 0.2s, padding-left 0.15s;
  position: relative;
}

.alert-card:hover {
  background: var(--glass);
  padding-left: calc(var(--sp-4) + 4px);
}

.alert-card.alert-danger  { border-left-color: var(--red); }
.alert-card.alert-warning { border-left-color: var(--yellow); }
.alert-card.alert-info    { border-left-color: var(--cyan); }
.alert-card.alert-success { border-left-color: var(--green); }

.alert-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.alert-title {
  font-weight: 500;
  font-size: 12px;
  flex: 1;
  min-width: 0;
}

.alert-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: 2px;
}

.alert-time {
  font-size: 10px;
  color: var(--text2);
}

.alert-relevance {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--cyan-dim);
  color: var(--cyan);
}

.alert-body {
  font-size: 11px;
  color: var(--text2);
  margin-top: 4px;
  padding-left: 28px;
  line-height: 1.4;
}

.alert-score-delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.04);
}

/* --- Alert Group (new) --- */
.alert-group {
  border-left: 3px solid transparent;
  margin-bottom: 1px;
}

.alert-group.alert-danger  { border-left-color: var(--red); }
.alert-group.alert-warning { border-left-color: var(--yellow); }
.alert-group.alert-info    { border-left-color: var(--cyan); }

.alert-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-4);
  cursor: pointer;
  transition: background 0.15s, padding-left 0.2s;
}

.alert-group-header:hover {
  background: var(--glass);
  padding-left: calc(var(--sp-4) + 2px);
}

.alert-group-left {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: 1;
  min-width: 0;
}

.alert-group-severity-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
}

.alert-group-severity-icon.sev-danger {
  background: var(--red-dim);
  box-shadow: 0 0 8px rgba(255, 68, 85, 0.3);
}

.alert-group-severity-icon.sev-warning {
  background: var(--yellow-dim);
  box-shadow: 0 0 8px rgba(255, 170, 0, 0.2);
}

.alert-group-severity-icon.sev-info {
  background: var(--cyan-dim);
}

.alert-group-token {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.alert-group-count {
  font-size: 10px;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

.alert-group-count.count-danger  { background: var(--red-dim); color: var(--red); }
.alert-group-count.count-warning { background: var(--yellow-dim); color: var(--yellow); }
.alert-group-count.count-info    { background: var(--cyan-dim); color: var(--cyan); }

.alert-group-detail {
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.alert-group-time {
  font-size: 10px;
  color: var(--text2);
  white-space: nowrap;
}

.alert-group-expanded {
  padding: 0 var(--sp-4) var(--sp-2);
}

.alert-group-expanded .alert-card {
  padding: var(--sp-1) var(--sp-3);
  border-left: none;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}

.alert-group-expanded .alert-card:last-child {
  border-bottom: none;
}

/* --- Score Display --- */
.score-display {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.score-bar {
  flex: 1;
  height: 6px;
  background: var(--glass2);
  border-radius: 3px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s ease-out;
}

.score-bar-fill.grade-a { background: var(--green); }
.score-bar-fill.grade-b { background: var(--cyan); }
.score-bar-fill.grade-c { background: var(--yellow); }
.score-bar-fill.grade-d { background: #ff8844; }
.score-bar-fill.grade-f { background: var(--red); }

.score-letter {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
  width: 24px;
  text-align: center;
}

/* --- Token Scanner Input --- */
.scanner-input-group {
  display: flex;
  gap: var(--sp-2);
}

.scanner-input-group .input {
  flex: 1;
}

/* --- Chat Bubble --- */
.chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 150;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  border: none;
  color: var(--bg);
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 240, 255, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0, 240, 255, 0.4);
}

/* --- Chat Panel --- */
.chat-panel {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 380px;
  height: 100vh;
  z-index: 160;
  background: var(--bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.chat-panel.open {
  transform: translateX(0);
}

.chat-panel-header {
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.chat-message {
  max-width: 85%;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.5;
}

.chat-message.user {
  align-self: flex-end;
  background: var(--cyan-dim);
  color: var(--text);
}

.chat-message.ai {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
}

.chat-panel-footer {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border);
}

.chat-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
}

.chat-prompt-btn {
  font-size: 11px;
  background: var(--glass2);
  border-color: var(--border2);
}

.chat-prompt-btn:hover {
  background: var(--cyan-dim);
  border-color: rgba(0, 240, 255, 0.2);
  color: var(--cyan);
}

.chat-message.ai .typing-indicator span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text2);
  margin: 0 2px;
  animation: pulse-dot 1s ease-in-out infinite;
}

.chat-message.ai .typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.chat-message.ai .typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

/* --- Upgrade Prompt --- */
.upgrade-prompt {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.08), rgba(255, 0, 170, 0.08));
  border: 1px solid rgba(0, 240, 255, 0.15);
  border-radius: var(--radius);
  padding: var(--sp-4);
  text-align: center;
}

.upgrade-prompt h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: var(--sp-2);
}

.upgrade-prompt p {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: var(--sp-3);
}

/* --- Onboarding Wizard --- */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
  animation: fadeUp 0.3s ease-out;
}

.onboarding-wizard {
  width: 100%;
  max-width: 520px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.onboarding-header {
  padding: var(--sp-6) var(--sp-6) var(--sp-4);
  text-align: center;
}

.onboarding-header h2 {
  font-size: 20px;
  font-weight: 700;
  margin-top: var(--sp-3);
}

.onboarding-header p {
  font-size: 13px;
  color: var(--text2);
  margin-top: var(--sp-1);
}

.onboarding-steps-indicator {
  display: flex;
  justify-content: center;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--glass2);
  transition: all 0.3s;
}

.step-dot.active {
  background: var(--cyan);
  width: 24px;
  border-radius: 4px;
}

.step-dot.done {
  background: var(--green);
}

.onboarding-body {
  padding: var(--sp-4) var(--sp-6);
  min-height: 200px;
}

.onboarding-step {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  animation: fadeUp 0.3s ease-out;
}

.onboarding-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--cyan-dim);
  color: var(--cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.onboarding-step.completed .onboarding-number {
  background: var(--green-dim);
  color: var(--green);
}

.onboarding-footer {
  padding: var(--sp-4) var(--sp-6);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
}

.onboarding-skip {
  font-size: 12px;
  color: var(--text2);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
}

.onboarding-skip:hover {
  color: var(--text);
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: var(--sp-6) var(--sp-4);
  color: var(--text2);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--sp-3);
  opacity: 0.7;
}

.empty-state-icon svg {
  width: 100%;
  height: 100%;
}

.empty-state h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--sp-1);
}

.empty-state p {
  font-size: 12px;
  max-width: 240px;
  margin: 0 auto;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Tablet: 2 columns */
@media (max-width: 1199px) {
  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
    padding: var(--sp-4);
  }

  .col-left {
    display: none;
  }
}

/* Mobile: 1 column + tab bar */
@media (max-width: 767px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
    padding: var(--sp-3);
    padding-bottom: 80px; /* room for tab bar */
  }

  .col-left, .col-right {
    display: none;
  }

  .col-right.mobile-visible {
    display: flex;
  }

  .mobile-tab-bar {
    display: block;
  }

  .top-nav {
    padding: var(--sp-3);
  }

  .top-nav-center {
    display: none;
  }

  .chat-bubble {
    bottom: 80px;
    right: 16px;
  }

  .chat-panel {
    width: 100%;
  }

  .portfolio-total {
    font-size: 28px;
  }
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
  animation: fadeUp 0.2s ease-out;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  animation: fadeUp 0.3s ease-out;
}

/* --- AI Summary Card (Outcrowd-inspired) --- */
.ai-summary-card {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.08), rgba(255, 0, 170, 0.05));
  border: 1px solid rgba(0, 240, 255, 0.15);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.05);
}

.ai-summary-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.ai-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
}

.ai-summary-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  font-weight: 450;
}

/* --- Greeting --- */
.greeting {
  padding: var(--sp-4) var(--sp-6);
}

.greeting-time {
  font-size: 12px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.greeting-name {
  font-size: 24px;
  font-weight: 700;
  margin-top: var(--sp-1);
}

/* --- Sparkline inline --- */
.sparkline-inline {
  display: inline-block;
  vertical-align: middle;
  width: 60px;
  height: 24px;
}

/* --- Stat pills row --- */
.stat-pills {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.stat-pill-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
}

/* --- Wallet list item --- */
.wallet-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  transition: background 0.2s, transform 0.15s;
  border-radius: var(--radius-sm);
}

.wallet-item:hover {
  background: var(--glass);
  transform: translateX(2px);
}

.wallet-addr {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text2);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wallet-chain-badge {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--cyan-dim);
  color: var(--cyan);
  text-transform: uppercase;
}

/* --- Utility classes --- */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-4 { margin-bottom: var(--sp-4); }

/* --- Sparkline --- */
.sparkline {
  width: 100%;
  height: 48px;
  margin-top: var(--sp-2);
}

.sparkline svg {
  width: 100%;
  height: 100%;
}

.sparkline-path {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sparkline-area {
  fill: url(#sparkline-gradient);
  opacity: 0.3;
}

/* --- Portfolio Value Styling --- */
.portfolio-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.portfolio-change {
  font-size: 13px;
  font-weight: 500;
  margin-top: 2px;
}

.text-green { color: var(--green); }
.text-red { color: var(--red); }

/* --- Stat Pills --- */
.stat-pills {
  display: flex;
  gap: var(--sp-4);
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}

.stat-pill {
  display: flex;
  align-items: baseline;
  gap: var(--sp-1);
}

.stat-pill-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.stat-pill-label {
  font-size: 10px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- Compact Alert Feed --- */
.alerts-compact-count {
  font-size: 10px;
  color: var(--text2);
  padding: var(--sp-1) 0;
  text-align: center;
  border-top: 1px solid var(--border);
}
