/* ═══════════════════════════════════════════
   DexToro — Design Tokens & Base
   ═══════════════════════════════════════════ */

:root {
  --black: #12121A;
  --grey-800: #171722;
  --grey-700: #1C1C28;
  --grey-600: #232334;
  --grey-500: #2D2D3D;
  --grey-400: #303044;
  --grey-200: #6F6E84;
  --grey-100: #C3C2D4;
  --white: #F7F7F7;
  --purple: #6666FF;
  --purple-hover: #7777FF;
  --green: #3FB68B;
  --red: #EF6868;

  --font: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 20px;

  --header-h: 48px;
  --footer-h: 40px;
  --sidebar-w: 320px;
}

/* ═══ LIGHT THEME ═══ */
[data-theme="light"] {
  --black: #FFFFFF;
  --grey-800: #F5F5F7;
  --grey-700: #FFFFFF;
  --grey-600: #F0F0F3;
  --grey-500: #E2E2E8;
  --grey-400: #D8D8E0;
  --grey-200: #8E8EA0;
  --grey-100: #5A5A6E;
  --white: #1A1A2E;
  --purple: #5555EE;
  --purple-hover: #4444DD;
  --green: #2DA672;
  --red: #D94545;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  color: var(--white);
  background: var(--grey-700);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input { font-family: inherit; outline: none; border: none; background: none; }
img { display: block; max-width: 100%; }

/* ═══ Typography helpers ═══ */
.text-white  { color: var(--white); }
.text-muted  { color: var(--grey-200); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-purple { color: var(--purple); }
.text-12 { font-size: 12px; line-height: 16px; }
.text-14 { font-size: 14px; line-height: 18px; }
.text-16 { font-size: 16px; line-height: 20px; }
.text-20 { font-size: 20px; line-height: 24px; }
.text-28 { font-size: 28px; line-height: 32px; }
.font-medium { font-weight: 500; }

/* ═══════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════ */
.header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--grey-700);
  border-bottom: 1px solid var(--grey-500);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
}

.header__left, .header__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header__logo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 12px;
}

.header__logo-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--white);
  letter-spacing: -0.3px;
}

.header__links {
  display: flex;
  align-items: center;
  gap: 0;
}

.header__link {
  padding: 8px 12px;
  font-size: 16px;
  color: var(--grey-200);
  transition: color 0.15s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}

.header__link:hover,
.header__link--active { color: var(--white); }

.header__link-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.header__divider-v {
  width: 1px;
  height: 33px;
  background: var(--grey-500);
  margin: 0 4px;
}

/* ═══════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  white-space: nowrap;
}

.btn--primary {
  background: var(--purple);
  color: var(--white);
  padding: 8px 16px;
  font-size: 12px;
}
.btn--primary:hover { background: var(--purple-hover); }

.btn--secondary {
  background: var(--grey-400);
  color: var(--white);
  padding: 8px 16px;
  font-size: 14px;
}
.btn--secondary:hover { background: #3a3a50; }

.btn--ghost {
  background: var(--grey-600);
  border: 1px solid var(--grey-500);
  color: var(--grey-200);
  padding: 8px 12px;
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.btn--icon {
  width: 40px; height: 40px;
  border: 1px solid var(--grey-500);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--grey-100);
}
.btn--icon:hover { border-color: var(--grey-400); }

.btn--round { border-radius: 50%; width: 32px; height: 32px; border: none; }

.btn--sm { padding: 8px 16px; font-size: 12px; }
.btn--xs { padding: 6px 10px; font-size: 11px; }
.btn--lg { padding: 14px 32px; font-size: 14px; border-radius: var(--radius-lg); }
.btn--full { width: 100%; }

/* ═══════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--header-h) - var(--footer-h));
  background: var(--grey-700);
  border-right: 1px solid var(--grey-500);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 50;
  overflow-y: auto;
}

.sidebar__top { padding: 0; }

.sidebar__section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
}

.sidebar__label {
  font-size: 12px;
  font-weight: 500;
  color: var(--grey-200);
  text-transform: uppercase;
  padding: 8px 16px;
  letter-spacing: 0.5px;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  padding: 0 16px;
  gap: 0;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--grey-200);
  transition: all 0.15s;
}

.sidebar__link:hover { color: var(--white); background: rgba(255,255,255,0.03); }

.sidebar__link--active {
  color: var(--white);
  background: var(--black);
}

.sidebar__icon {
  width: 24px;
  height: 24px;
  border-radius: 12px;
  background: var(--grey-400);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar__bottom { padding: 16px; }

.sidebar__buttons {
  display: flex;
  gap: 12px;
}

.sidebar__buttons .btn { flex: 1; }

/* ═══════════════════════════════════════════
   CONTENT
   ═══════════════════════════════════════════ */
.main-layout {
  display: flex;
  padding-top: var(--header-h);
  height: calc(100vh - var(--footer-h));
}

.content {
  margin-left: var(--sidebar-w);
  flex: 1;
  overflow-y: auto;
  padding: 40px;
  height: calc(100vh - var(--header-h) - var(--footer-h));
}

.page { display: none; }
.page--active { display: block; }

/* ═══════════════════════════════════════════
   PORTFOLIO CARD
   ═══════════════════════════════════════════ */
.portfolio-card {
  display: flex;
  border: 1px solid var(--grey-500);
  border-radius: var(--radius-sm);
  overflow: hidden;
  height: 320px;
  margin-bottom: 40px;
}

.portfolio-card__left {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.portfolio-card__info {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.portfolio-card__row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.portfolio-card__stats {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.portfolio-card__stat {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.portfolio-card__stat--border-top { border-top: 1px solid var(--grey-500); }
.portfolio-card__stat--border-right { border-right: 1px solid var(--grey-500); }

.portfolio-card__stat-row {
  display: flex;
  border-top: 1px solid var(--grey-500);
}

.portfolio-card__stat-row > div { flex: 1; }

.portfolio-card__right {
  flex: 1;
  border-left: 1px solid var(--grey-500);
  background:
    radial-gradient(ellipse at 30% 50%, rgba(102,102,255,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 30%, rgba(63,182,139,0.05) 0%, transparent 50%),
    var(--grey-800);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.portfolio-card__right::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(45,45,61,0.3) 39px, rgba(45,45,61,0.3) 40px),
    repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(45,45,61,0.3) 39px, rgba(45,45,61,0.3) 40px);
  opacity: 0.5;
}

.portfolio-card__welcome {
  position: relative;
  z-index: 1;
  background: var(--grey-700);
  padding: 24px 40px;
  border-radius: var(--radius-sm);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.portfolio-card__welcome .btn { margin-top: 8px; }

/* ═══════════════════════════════════════════
   SECTIONS & TABLE
   ═══════════════════════════════════════════ */
.section { margin-bottom: 40px; }

.section__title {
  font-size: 20px;
  font-weight: 500;
  color: var(--white);
  margin-bottom: 24px;
  padding-left: 16px;
}

.section__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0 16px;
  margin-bottom: 24px;
}

.section__filters {
  display: flex;
  align-items: center;
  gap: 12px;
}

.empty-state {
  background: var(--grey-800);
  border: 1px solid var(--grey-500);
  border-radius: var(--radius-lg);
  padding: 16px;
  color: var(--grey-200);
  font-size: 14px;
}

/* Tags */
.tag-group { display: flex; gap: 6px; }

.tag {
  padding: 8px 16px;
  border-radius: var(--radius-xl);
  font-size: 12px;
  color: var(--grey-100);
  background: var(--grey-400);
  transition: all 0.15s;
  cursor: pointer;
  border: none;
}

.tag--active {
  background: var(--grey-800);
  color: var(--white);
}

.tag:hover { opacity: 0.85; }

/* Search input */
.search-input {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--grey-600);
  border: 1px solid var(--grey-500);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.search-input input {
  color: var(--white);
  font-size: 14px;
  width: 160px;
}

.search-input input::placeholder { color: var(--grey-200); }

/* Table */
.table-container {
  border: 1px solid var(--grey-500);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table__th {
  background: var(--grey-800);
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 400;
  color: var(--grey-200);
  text-align: left;
  border-bottom: 1px solid var(--grey-500);
  white-space: nowrap;
}

.sort-arrows {
  font-size: 8px;
  color: var(--grey-200);
  margin-left: 4px;
  letter-spacing: -2px;
}

.table__td {
  padding: 8px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--grey-500);
  vertical-align: middle;
}

.table tbody tr {
  background: var(--grey-700);
  transition: background 0.1s;
  cursor: pointer;
}

.table tbody tr:hover { background: var(--grey-600); }
.table tbody tr:last-child .table__td { border-bottom: none; }

.market-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.market-cell__icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--grey-400);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--white);
  flex-shrink: 0;
  overflow: hidden;
}

.market-cell__icon img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.market-cell__name {
  display: flex;
  flex-direction: column;
}

.market-cell__pair {
  font-size: 14px;
  color: var(--white);
  line-height: 20px;
}

.market-cell__label {
  font-size: 12px;
  color: var(--grey-200);
  line-height: 16px;
}

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

.oi-cell {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 16px;
}

/* ═══════════════════════════════════════════
   TRADE PAGE
   ═══════════════════════════════════════════ */
.trade-layout {
  display: flex;
  gap: 0;
  height: calc(100vh - var(--header-h) - var(--footer-h));
  margin: -40px;
}

/* Trade page goes full-width: hide sidebar, expand content */
body.trade-active .sidebar { display: none; }
body.trade-active .content { margin-left: 0; }

.trade-left {
  width: 320px;
  flex-shrink: 0;
  border-right: 1px solid var(--grey-500);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.trade-pair-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--grey-500);
  height: 48px;
}

.trade-pair-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.trade-pair-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--grey-400);
}

.trade-wallet-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--grey-500);
}

.trade-wallet-info > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.trade-market-info {
  padding: 8px 16px;
  border-bottom: 1px solid var(--grey-500);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.trade-market-info__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.trade-orderbook {
  flex: 1;
  overflow-y: auto;
}

.trade-orderbook__header {
  padding: 8px 16px;
  border-bottom: 1px solid var(--grey-500);
}

.trade-orderbook__content {
  padding: 4px 0;
}

.orderbook-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 16px;
  font-size: 12px;
  position: relative;
}

.orderbook-row--ask { color: var(--red); }
.orderbook-row--bid { color: var(--green); }

.orderbook-row__bar {
  position: absolute;
  top: 0; bottom: 0;
  right: 0;
  opacity: 0.08;
}

.orderbook-row--ask .orderbook-row__bar { background: var(--red); }
.orderbook-row--bid .orderbook-row__bar { background: var(--green); }

.orderbook-spread {
  padding: 6px 16px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--white);
  border-top: 1px solid var(--grey-500);
  border-bottom: 1px solid var(--grey-500);
}

.trade-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* old chart header overridden at bottom */

.trade-chart-tabs {
  display: flex;
  gap: 0;
}

.trade-chart-tab {
  padding: 8px 16px;
  font-size: 12px;
  color: var(--grey-200);
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.trade-chart-tab--active {
  color: var(--white);
  border-bottom-color: var(--purple);
}

/* timeframes now inline in chart header */

.timeframe-btn {
  padding: 4px 8px;
  font-size: 12px;
  color: var(--grey-200);
  border-radius: 4px;
  transition: all 0.15s;
}

.timeframe-btn--active {
  color: var(--white);
  background: var(--grey-400);
}

.trade-chart {
  flex: 1;
  min-height: 350px;
  background: var(--grey-800);
  position: relative;
}

.trade-positions {
  border-top: 1px solid var(--grey-500);
}

.trade-positions__tabs {
  display: flex;
  border-bottom: 1px solid var(--grey-500);
}

.trade-positions__tab {
  padding: 10px 20px;
  font-size: 12px;
  color: var(--grey-200);
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.trade-positions__tab--active {
  color: var(--white);
  border-bottom-color: var(--purple);
}

.trade-right {
  width: 340px;
  flex-shrink: 0;
  border-left: 1px solid var(--grey-500);
  overflow-y: auto;
}

.trade-order-panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.trade-order-tabs {
  display: flex;
  gap: 0;
  background: var(--grey-600);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.trade-order-tab {
  flex: 1;
  padding: 10px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  transition: all 0.15s;
  color: var(--grey-200);
}

.trade-order-tab--active.trade-order-tab--long {
  background: rgba(63,182,139,0.15);
  color: var(--green);
}

.trade-order-tab--active.trade-order-tab--short {
  background: rgba(239,104,104,0.15);
  color: var(--red);
}

.trade-order-type {
  display: flex;
  gap: 4px;
}

.order-type-btn {
  padding: 6px 12px;
  font-size: 12px;
  color: var(--grey-200);
  border-radius: 6px;
  transition: all 0.15s;
}

.order-type-btn--active {
  background: var(--grey-400);
  color: var(--white);
}

.trade-order-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.input-group {
  display: flex;
  align-items: center;
  background: var(--grey-600);
  border: 1px solid var(--grey-500);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  height: 44px;
  box-shadow: 0 0.5px 0 rgba(255,255,255,0.08);
}

.input {
  flex: 1;
  color: var(--white);
  font-size: 16px;
  background: none;
  height: 100%;
}

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

.input-suffix {
  font-size: 12px;
  color: var(--grey-100);
  flex-shrink: 0;
}

.leverage-slider { padding: 8px 0; }

.slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--grey-400);
  outline: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--purple);
  cursor: pointer;
  border: 2px solid var(--grey-700);
}

.leverage-marks {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--grey-200);
  margin-top: 4px;
}

.leverage-value {
  text-align: center;
  padding: 4px 0;
}

.trade-order-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--grey-500);
}

.trade-order-info__row {
  display: flex;
  justify-content: space-between;
}

/* ═══════════════════════════════════════════
   REWARDS PAGE
   ═══════════════════════════════════════════ */
.rewards-hero {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}

.rewards-hero__left {
  width: 488px;
  flex-shrink: 0;
  background:
    radial-gradient(ellipse at 80% 20%, rgba(102,102,255,0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 90% 90%, rgba(63,182,139,0.08) 0%, transparent 40%),
    var(--grey-800);
  border: 1px solid var(--grey-500);
  border-radius: var(--radius-md);
  padding: 40px 24px 24px;
  position: relative;
  overflow: hidden;
}

.rewards-hero__intro {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.rewards-hero__buttons {
  display: flex;
  gap: 8px;
}

.rewards-hero__right {
  flex: 1;
  background: var(--grey-800);
  border: 1px solid var(--grey-500);
  border-radius: var(--radius-md);
  padding: 24px 40px;
}

.rewards-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  height: 100%;
}

.rewards-stat {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rewards-stat__label {
  font-size: 20px !important;
  font-weight: 500;
  color: var(--white) !important;
}

.rewards-stat__group {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rewards-stat__item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Rewards metric cards */
.rewards-cards-row {
  display: flex;
  gap: 20px;
  margin-bottom: 32px;
}

.rewards-metric-card {
  flex: 1;
  background: var(--grey-800);
  border: 1px solid var(--grey-500);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rewards-metric-card__value {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.progress-bar {
  height: 5px;
  background: var(--grey-500);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  background: var(--purple);
  border-radius: 3px;
  transition: width 0.6s ease;
}

/* Rewards section header */
.rewards-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.rewards-tabs { display: flex; gap: 8px; }

/* Rewards panels */
.rewards-panels {
  display: flex;
  gap: 20px;
}

.rewards-panel {
  background: var(--grey-800);
  border: 1px solid var(--grey-500);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.rewards-panel--trading {
  width: 480px;
  flex-shrink: 0;
  padding: 24px;
}

.rewards-panel--staking { flex: 1; }

.rewards-panel__header { margin-bottom: 20px; }

.rewards-panel__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.rewards-panel__stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rewards-panel__split {
  display: flex;
  height: 100%;
}

.rewards-panel__stake-form {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--grey-500);
}

.rewards-panel__form-tabs {
  display: flex;
  background: var(--grey-600);
  border: 1px solid var(--grey-500);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.rewards-panel__form-tab {
  flex: 1;
  padding: 12px;
  font-size: 14px;
  text-align: center;
  color: var(--grey-200);
  transition: all 0.15s;
}

.rewards-panel__form-tab--active {
  background: var(--grey-500);
  color: var(--white);
}

.rewards-panel__staking-rewards {
  width: 320px;
  flex-shrink: 0;
  padding: 24px;
}

.staking-reward-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
}

.staking-reward-divider {
  height: 1px;
  background: var(--grey-500);
}

.staking-reward-buttons {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.staking-reward-buttons .btn { flex: 1; }

/* ═══════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.modal-overlay--active { display: flex; }

.modal {
  width: 750px;
  background: var(--grey-700);
  border: 1px solid var(--grey-500);
  border-radius: var(--radius-md);
  overflow: hidden;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--grey-500);
}

.modal__close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s;
}

.modal__close:hover { background: var(--grey-400); }

.modal__body {
  display: flex;
  padding: 0 20px 20px;
}

.modal__sidebar {
  width: 172px;
  flex-shrink: 0;
  border-right: 1px solid var(--grey-500);
  padding: 10px 20px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal__sidebar-item {
  text-align: left;
  padding: 8px;
  font-size: 16px;
  color: var(--grey-200);
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  width: 100%;
}

.modal__sidebar-item--active {
  background: var(--black);
  color: var(--white);
}

.modal__sidebar-item:hover { color: var(--white); }

.modal__content {
  flex: 1;
  padding: 10px 0 0 20px;
}

.modal__field {
  margin-top: 16px;
}

.modal__field-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.modal__notice {
  background: var(--grey-400);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin: 16px 0;
  font-size: 12px;
  color: var(--grey-200);
  text-align: center;
}

/* ═══════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════ */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--footer-h);
  background: var(--grey-700);
  border-top: 1px solid var(--grey-500);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
}

.footer__left, .footer__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.footer__left { gap: 24px; }

.footer__status, .footer__help {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3.5px rgba(63,182,139,0.2);
}

/* ═══════════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--grey-400); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--grey-200); }

/* ═══════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Row fade-in only on initial build (class added by JS) */
.table tbody tr.row-enter {
  animation: fadeIn 0.3s ease backwards;
}

.table tbody tr.row-enter:nth-child(1) { animation-delay: 0.02s; }
.table tbody tr.row-enter:nth-child(2) { animation-delay: 0.04s; }
.table tbody tr.row-enter:nth-child(3) { animation-delay: 0.06s; }
.table tbody tr.row-enter:nth-child(4) { animation-delay: 0.08s; }
.table tbody tr.row-enter:nth-child(5) { animation-delay: 0.10s; }
.table tbody tr.row-enter:nth-child(6) { animation-delay: 0.12s; }
.table tbody tr.row-enter:nth-child(7) { animation-delay: 0.14s; }
.table tbody tr.row-enter:nth-child(8) { animation-delay: 0.16s; }
.table tbody tr.row-enter:nth-child(9) { animation-delay: 0.18s; }
.table tbody tr.row-enter:nth-child(10) { animation-delay: 0.20s; }

/* Price flash animation */
@keyframes priceFlashGreen {
  0% { background: rgba(63,182,139,0.15); }
  100% { background: transparent; }
}

@keyframes priceFlashRed {
  0% { background: rgba(239,104,104,0.15); }
  100% { background: transparent; }
}

.flash-green { animation: priceFlashGreen 0.6s ease; }
.flash-red { animation: priceFlashRed 0.6s ease; }

/* ═══════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════ */
.toast-container {
  position: fixed;
  top: 60px;
  right: 16px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--white);
  background: var(--grey-600);
  border: 1px solid var(--grey-500);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  transform: translateX(120%);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  max-width: 380px;
}

.toast--show {
  transform: translateX(0);
  opacity: 1;
}

.toast--success { border-left: 3px solid var(--green); }
.toast--error { border-left: 3px solid var(--red); }
.toast--info { border-left: 3px solid var(--purple); }

/* ═══════════════════════════════════════════
   CONNECTED WALLET BUTTON
   ═══════════════════════════════════════════ */
.btn--connected {
  background: var(--grey-600) !important;
  border: 1px solid var(--grey-500);
  font-size: 12px !important;
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 0.3px;
}

.btn--connected:hover {
  background: var(--grey-400) !important;
}

/* ═══════════════════════════════════════════
   MAX BUTTON IN INPUTS
   ═══════════════════════════════════════════ */
.input-max-btn {
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--purple);
  background: rgba(102,102,255,0.1);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  margin-right: 8px;
  transition: background 0.15s;
  flex-shrink: 0;
}

.input-max-btn:hover {
  background: rgba(102,102,255,0.2);
}

/* ═══════════════════════════════════════════
   TOGGLE SWITCH
   ═══════════════════════════════════════════ */
.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle__slider {
  position: absolute;
  inset: 0;
  background: var(--grey-400);
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle__slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: var(--white);
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle input:checked + .toggle__slider {
  background: var(--purple);
}

.toggle input:checked + .toggle__slider::before {
  transform: translateX(18px);
}

/* ═══════════════════════════════════════════
   POSITIONS TABLE VISIBILITY
   ═══════════════════════════════════════════ */
.trade-positions__panel { min-height: 60px; }

/* Orderbook spread enhanced */
.orderbook-spread {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* ═══════════════════════════════════════════
   SKELETON LOADERS
   ═══════════════════════════════════════════ */
.skeleton-row td { padding: 12px 16px !important; }

.skeleton {
  background: var(--grey-600);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.skeleton--circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton--text {
  height: 14px;
  width: 80px;
}

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

.skeleton--text-sm {
  height: 12px;
  width: 70px;
  margin-top: 4px;
}

.skeleton--text-short {
  height: 14px;
  width: 50px;
}

.skeleton-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.skeleton-lines {
  display: flex;
  flex-direction: column;
}

/* ═══════════════════════════════════════════
   NETWORK DROPDOWN
   ═══════════════════════════════════════════ */
.header__link--dropdown {
  position: relative;
  cursor: pointer;
  user-select: none;
}

.header__link-dot--yellow { background: #F5A623; }

.net-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--grey-800);
  border: 1px solid var(--grey-500);
  border-radius: var(--radius-sm);
  min-width: 180px;
  padding: 4px;
  z-index: 300;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.net-dropdown--open { display: block; }

.net-dropdown__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--grey-200);
  border: none;
  background: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.12s;
  text-align: left;
}

.net-dropdown__item:hover { background: var(--grey-600); color: var(--white); }
.net-dropdown__item--active { color: var(--white); background: var(--grey-600); }

/* ═══════════════════════════════════════════
   HAMBURGER (hidden on desktop)
   ═══════════════════════════════════════════ */
.hamburger {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--grey-200);
  cursor: pointer;
  flex-shrink: 0;
}

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 49;
}

.mobile-overlay--open { display: block; }

/* ═══════════════════════════════════════════
   CHART HEADER DIVIDER
   ═══════════════════════════════════════════ */
.trade-chart-divider {
  width: 1px;
  height: 16px;
  background: var(--grey-500);
  margin: 0 8px;
  flex-shrink: 0;
}

.trade-chart-header {
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 40px;
  border-bottom: 1px solid var(--grey-500);
  gap: 0;
  justify-content: flex-start;
}

/* ═══════════════════════════════════════════
   RESPONSIVE — TABLET (≤1024px)
   ═══════════════════════════════════════════ */
@media (max-width: 1024px) {
  .sidebar { display: none; }
  .content { margin-left: 0 !important; }
  .hamburger { display: flex; }

  .sidebar--open {
    display: flex;
    z-index: 200;
    position: fixed;
    top: var(--header-h);
    left: 0;
    width: 280px;
    height: calc(100vh - var(--header-h));
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
  }

  .portfolio-card { flex-direction: column; height: auto; }
  .portfolio-card__left { width: 100%; }
  .portfolio-card__right { border-left: none; border-top: 1px solid var(--grey-500); min-height: 200px; }

  .trade-layout { flex-direction: column; height: auto; margin: -24px; }
  .trade-left { width: 100%; max-height: 300px; border-right: none; border-bottom: 1px solid var(--grey-500); }
  .trade-center { min-height: 400px; }
  .trade-right { width: 100%; border-left: none; border-top: 1px solid var(--grey-500); }

  .rewards-hero { flex-direction: column; }
  .rewards-hero__left { width: 100%; }
  .rewards-cards-row { flex-direction: column; }
  .rewards-panels { flex-direction: column; }
  .rewards-panel--trading { width: 100%; }

  .rewards-stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ═══════════════════════════════════════════
   RESPONSIVE — MOBILE (≤768px)
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
  .header__links { display: none; }
  .header__divider-v { display: none; }
  .header__right .btn--icon { display: flex; }

  .content { padding: 16px; }

  .trade-layout { margin: -16px; }
  .trade-left { max-height: 250px; }
  .trade-chart { min-height: 280px; }

  .portfolio-card__stat-row { flex-direction: column; }
  .portfolio-card__stat--border-right { border-right: none; border-bottom: 1px solid var(--grey-500); }

  .rewards-stats-grid { grid-template-columns: 1fr; }
  .rewards-panel__split { flex-direction: column; }
  .rewards-panel__stake-form { border-right: none; border-bottom: 1px solid var(--grey-500); }
  .rewards-panel__staking-rewards { width: 100%; }

  .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { min-width: 700px; }

  .modal { width: calc(100vw - 32px); max-height: 90vh; overflow-y: auto; }
  .modal__body { flex-direction: column; }
  .modal__sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--grey-500); padding: 8px 0; flex-direction: row; overflow-x: auto; gap: 4px; }
  .modal__sidebar-item { white-space: nowrap; padding: 6px 12px; font-size: 14px; }
  .modal__content { padding: 16px 0 0; }

  .footer__left { gap: 12px; }
  .toast { max-width: calc(100vw - 32px); }

  .rewards-section-header { flex-direction: column; gap: 12px; align-items: flex-start; }
}
