
@import './tokens.css';

/* ─── reset / base ────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: var(--st-bg);
  color: var(--st-text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--st-accent-dim); border-radius: 99px; }

/* ─── layout ──────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

/* ─── sidebar ─────────────────────────────────────────── */
.sidebar {
  background: var(--st-surface);
  border-right: 1px solid var(--st-border);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 24px;
  border-bottom: 1px solid var(--st-border);
  margin-bottom: 8px;
}

.sidebar-logo-mark {
  width: 32px;
  height: 32px;
  background: var(--st-accent);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 0 16px rgba(108, 71, 255, 0.5);
  flex-shrink: 0;
}

.sidebar-logo-name {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--st-text);
}

.sidebar-logo-name span {
  color: var(--st-muted);
  font-size: 11px;
  display: block;
  letter-spacing: 0.04em;
}

.nav-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--st-muted);
  padding: 16px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--st-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border: 1px solid transparent;
  user-select: none;
}

.nav-item i {
  width: 20px;
  font-size: 0.9rem;
  text-align: center;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.nav-item:hover {
  background: rgba(108, 71, 255, 0.08);
  color: var(--st-text);
}
.nav-item:hover i { opacity: 1; }

.nav-item.active {
  background: rgba(108, 71, 255, 0.14);
  color: var(--st-accent-2);
  border-color: rgba(108, 71, 255, 0.2);
}
.nav-item.active i { opacity: 1; }

.nav-item .badge {
  margin-left: auto;
  background: var(--st-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--st-border);
  position: relative;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.user-row:hover,
.user-row.open {
  background: rgba(108, 71, 255, 0.08);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--st-accent), var(--st-accent-2));
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--st-text);
  line-height: 1.2;
}

.user-role {
  font-size: 11px;
  color: var(--st-muted);
}

.user-chevron {
  margin-left: auto;
  color: var(--st-muted);
  font-size: 0.7rem;
  transition: transform 0.2s;
}
.user-row.open .user-chevron {
  transform: rotate(180deg);
}

/* Profile dropdown */
.profile-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--st-card);
  border: 1px solid var(--st-border);
  border-radius: 12px;
  padding: 8px;
  box-shadow: var(--glow-card);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.18s, transform 0.18s, visibility 0.18s;
  z-index: 50;
}

.profile-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.profile-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--st-muted);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.profile-dropdown-item:hover {
  background: rgba(108, 71, 255, 0.1);
  color: var(--st-text);
}

.profile-dropdown-item i {
  width: 18px;
  text-align: center;
  opacity: 0.8;
}

.profile-dropdown-divider {
  height: 1px;
  background: var(--st-border);
  margin: 6px 0;
}

.profile-dropdown-item.danger {
  color: var(--st-red);
}
.profile-dropdown-item.danger:hover {
  background: rgba(255, 77, 106, 0.1);
}

/* ─── main ────────────────────────────────────────────── */
.main {
  overflow-y: auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ─── topbar ──────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-title h1 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--st-text);
}

.topbar-title p {
  font-size: 12px;
  color: var(--st-muted);
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  outline: none;
}

.btn-ghost {
  background: transparent;
  color: var(--st-muted);
  border: 1px solid var(--st-border);
}
.btn-ghost:hover {
  background: rgba(108, 71, 255, 0.08);
  color: var(--st-text);
  border-color: rgba(108, 71, 255, 0.25);
}

.btn-primary {
  background: var(--st-accent);
  color: #fff;
  box-shadow: 0 0 20px rgba(108, 71, 255, 0.35);
}
.btn-primary:hover {
  background: #7d5cff;
  box-shadow: 0 0 28px rgba(108, 71, 255, 0.5);
  transform: translateY(-1px);
}

.btn i { font-size: 0.8rem; }

/* period tabs */
.period-tabs {
  display: flex;
  background: var(--st-surface);
  border: 1px solid var(--st-border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.period-tab {
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--st-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}
.period-tab.active {
  background: var(--st-accent);
  color: #fff;
}
.period-tab:not(.active):hover {
  color: var(--st-text);
}

/* live badge */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 229, 160, 0.08);
  border: 1px solid rgba(0, 229, 160, 0.2);
  border-radius: 99px;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--st-green);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.live-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--st-green);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(0, 229, 160, 0.4); }
  50%       { opacity: 0.7; box-shadow: 0 0 0 5px rgba(0, 229, 160, 0); }
}

/* ─── kpi row ─────────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.kpi-card {
  background: var(--st-card);
  border: 1px solid var(--st-border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
  animation: fadeUp 0.5s ease both;
}

.kpi-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 80% at 100% 0%, rgba(108, 71, 255, 0.06), transparent);
  pointer-events: none;
}

.kpi-card:hover {
  border-color: rgba(108, 71, 255, 0.3);
  box-shadow: var(--glow-card);
}

.kpi-card:nth-child(1) { animation-delay: 0.05s; }
.kpi-card:nth-child(2) { animation-delay: 0.10s; }
.kpi-card:nth-child(3) { animation-delay: 0.15s; }
.kpi-card:nth-child(4) { animation-delay: 0.20s; }

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

.kpi-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--st-muted);
}

.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  background: rgba(108, 71, 255, 0.08);
  color: #6c47ff;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 400;
  color: var(--st-text);
  letter-spacing: -0.02em;
  line-height: 1;
}

.kpi-delta {
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}
.kpi-delta.up   { color: var(--st-green); }
.kpi-delta.down { color: var(--st-red); }

.kpi-sub {
  font-size: 11px;
  color: var(--st-muted);
  margin-left: 4px;
}

/* ─── main grid ───────────────────────────────────────── */
.grid-main {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
  animation: fadeUp 0.5s ease both;
  animation-delay: 0.25s;
}

/* ─── chart card ──────────────────────────────────────── */
.chart-card {
  background: var(--st-card);
  border: 1px solid var(--st-border);
  border-radius: 18px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 380px;
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.chart-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--st-text);
}

.chart-card-sub {
  font-size: 12px;
  color: var(--st-muted);
  margin-top: 2px;
}

.legend {
  display: flex;
  gap: 14px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--st-muted);
}

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

/* ProvChart host — fixed box so injected chart has a paint surface */
.provchart-host {
  width: 100%;
  height: 280px;
  min-height: 280px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.provchart-host .pc-loading {
  color: var(--st-muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.provchart-host .pc-error {
  color: var(--st-red);
  font-size: 13px;
  text-align: center;
  padding: 20px;
  line-height: 1.5;
}



/* ─── right panel ─────────────────────────────────────── */
.panel-right {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.alloc-card,
.activity-card {
  background: var(--st-card);
  border: 1px solid var(--st-border);
  border-radius: 18px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.alloc-title,
.activity-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--st-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.alloc-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.alloc-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.alloc-name {
  font-size: 13px;
  color: var(--st-text);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alloc-pct {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--st-muted);
}

.bar-track {
  height: 5px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 99px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(90deg, var(--bar-color), color-mix(in srgb, var(--bar-color) 70%, white));
}

/* activity */
.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.activity-item:last-child { border-bottom: none; }

.activity-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.activity-icon.buy  { background: rgba(0, 229, 160, 0.1); color: var(--st-green); }
.activity-icon.sell { background: rgba(255, 77, 106, 0.1); color: var(--st-red); }
.activity-icon.swap { background: rgba(108, 71, 255, 0.1); color: var(--st-accent-2); }

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

.activity-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--st-text);
}

.activity-time {
  font-size: 11px;
  color: var(--st-muted);
  margin-top: 1px;
}

.activity-amount {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}
.activity-amount.up   { color: var(--st-green); }
.activity-amount.down { color: var(--st-red); }

/* ─── bottom row ──────────────────────────────────────── */
.grid-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  animation: fadeUp 0.5s ease both;
  animation-delay: 0.3s;
}

.spark-card {
  background: var(--st-card);
  border: 1px solid var(--st-border);
  border-radius: 18px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.spark-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.spark-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--st-text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.spark-sub {
  font-size: 11px;
  color: var(--st-muted);
  margin-top: 2px;
}

.spark-value {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  color: var(--st-text);
  letter-spacing: -0.02em;
}

.spark-delta {
  font-size: 12px;
  font-weight: 600;
  margin-top: 3px;
}
.spark-delta.up   { color: var(--st-green); }
.spark-delta.down { color: var(--st-red); }

.spark-chart-host,
.spark-chart-host.provchart-host {
  width: 100%;
  min-height: 120px;
  height: 120px;
  overflow: hidden;
}

/* ─── overview stats strip ────────────────────────────── */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  animation: fadeUp 0.5s ease both;
  animation-delay: 0.22s;
}

.stat-pill {
  background: var(--st-surface);
  border: 1px solid var(--st-border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-pill-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  background: rgba(108, 71, 255, 0.1);
  color: var(--st-accent-2);
}

.stat-pill-label {
  font-size: 11px;
  color: var(--st-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-pill-value {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--st-text);
  margin-top: 2px;
}

/* ─── animations ──────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── responsive ──────────────────────────────────────── */
@media (max-width: 1100px) {
  .kpi-row,
  .stats-strip { grid-template-columns: repeat(2, 1fr); }
  .grid-main { grid-template-columns: 1fr; }
  .grid-bottom { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 20px 16px; }
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 12px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-actions { flex-wrap: wrap; }
}


