:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(15, 23, 42, 0.08);
  --shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
  --primary: #4f46e5;
  --primary-2: #06b6d4;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --sidebar: #0f172a;
  --sidebar-text: #e2e8f0;
  --sidebar-muted: #94a3b8;
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
}

body.dark {
  --bg: #07111f;
  --panel: #0f172a;
  --panel-2: #111c31;
  --text: #f8fafc;
  --muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.14);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  --primary: #818cf8;
  --primary-2: #22d3ee;
  --success: #34d399;
  --danger: #fb7185;
  --warning: #fbbf24;
  --sidebar: #020817;
  --sidebar-text: #f8fafc;
  --sidebar-muted: #94a3b8;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

body {
  transition: background 0.25s ease, color 0.25s ease;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar), #111827);
  color: var(--sidebar-text);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 16px 36px rgba(79, 70, 229, 0.35);
}

.brand-copy h1 {
  margin: 0;
  font-size: 1.1rem;
}

.brand-copy p {
  margin: 4px 0 0;
  color: var(--sidebar-muted);
  font-size: 0.92rem;
}

.nav {
  display: grid;
  gap: 10px;
}

.nav-link {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 14px;
  color: var(--sidebar-text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: transform 0.2s ease, background 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255, 255, 255, 0.08);
  transform: translateX(3px);
}

.sidebar-panel {
  margin-top: auto;
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-label {
  display: inline-block;
  color: var(--sidebar-muted);
  margin-bottom: 10px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-panel strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 8px;
}

.sidebar-panel p {
  margin: 0;
  color: var(--sidebar-muted);
  line-height: 1.5;
  font-size: 0.92rem;
}

.main {
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

.topbar h2 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.15;
}

.topbar-subtext {
  margin: 10px 0 0;
  color: var(--muted);
  max-width: 760px;
  line-height: 1.6;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 22px;
}

.toolbar-group {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.range-switch {
  display: inline-flex;
  padding: 5px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.range-btn {
  min-width: 108px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

.range-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #ffffff;
  box-shadow: 0 12px 26px rgba(79, 70, 229, 0.22);
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 600;
}

.field input {
  min-width: 170px;
  height: 46px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  outline: none;
}

.button {
  height: 46px;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #ffffff;
  border: none;
}

.button.secondary {
  background: var(--panel);
  color: var(--text);
}

.button.ghost {
  background: var(--panel);
  color: var(--text);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.stat-card,
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  min-height: 132px;
}

.stat-copy {
  display: grid;
  gap: 10px;
}

.stat-label {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.stat-change {
  font-size: 0.9rem;
  font-weight: 700;
}

.positive {
  color: var(--success);
}

.negative {
  color: var(--danger);
}

.neutral {
  color: var(--warning);
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: rgba(79, 70, 229, 0.12);
  color: var(--primary);
  font-size: 1.3rem;
  font-weight: 800;
  flex-shrink: 0;
}

.skeleton-card {
  position: relative;
  overflow: hidden;
}

.skeleton-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(148, 163, 184, 0.18), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

.charts-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.bottom-charts {
  grid-template-columns: 1fr 1fr;
}

.card {
  padding: 20px;
}

.chart-card.wide {
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.card-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.card-head p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.93rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
}

.chart-box {
  position: relative;
  height: 340px;
}

.table-grid {
  display: grid;
  grid-template-columns: 1fr;
}

.table-card {
  overflow: hidden;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  font-size: 0.86rem;
  color: var(--muted);
  font-weight: 700;
  padding: 0 0 14px;
}

tbody td {
  padding: 16px 0;
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
  white-space: nowrap;
}

.asset-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.asset-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--panel-2);
}

.asset-meta {
  display: grid;
  gap: 2px;
}

.asset-name {
  font-weight: 700;
}

.asset-symbol {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.82rem;
}

.last-updated {
  color: var(--muted);
}

@media (max-width: 1240px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .charts-grid,
  .bottom-charts {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    gap: 20px;
  }

  .sidebar-panel {
    margin-top: 0;
  }
}

@media (max-width: 720px) {
  .main {
    padding: 18px;
  }

  .topbar {
    flex-direction: column;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar-group {
    width: 100%;
  }

  .range-switch {
    width: 100%;
  }

  .range-btn {
    flex: 1;
    min-width: 0;
  }

  .date-controls,
  .export-controls {
    width: 100%;
  }

  .field,
  .field input,
  .button {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .chart-box {
    height: 300px;
  }
}