@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../assets/fonts/inter-latin.woff2') format('woff2');
}

/* === THEME TOKENS === */
:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #080f1a;
  --text-primary: #f4f7fb;
  --text-strong: #edf2f8;
  --text-secondary: #c3cede;
  --text-muted: #a9b7cc;
  --text-soft: #b7c5d8;
  --text-placeholder: #a4b3c8;
  --action-bg: #1673d1;
  --action-bg-hover: #0f63b8;
  --action-border: rgba(82,179,255,.35);
  --action-border-hover: #52b3ff;
  --action-shadow: 0 8px 20px rgba(3,12,26,.28);
  --action-shadow-hover: 0 10px 24px rgba(3,12,26,.36);
  --notice-bg: rgba(22,115,209,.1);
  --notice-border: rgba(82,179,255,.28);
  --notice-text: #d5e2f1;
  --sidebar-bg: linear-gradient(180deg, #1d2c47 0%, #1a2942 45%, #162238 100%);
  --sidebar-border: rgba(169,183,204,.1);
  --balance-bg: #213454;
  --balance-border: rgba(82,179,255,.18);
  --balance-shadow: 0 6px 16px rgba(3,12,26,.16);
  --nav-text: #b0bed1;
  --nav-hover-bg: rgba(82,179,255,.08);
  --nav-hover-text: #edf5ff;
  --nav-active-bg: rgba(22,115,209,.22);
  --nav-active-text: #f4f8ff;
  --nav-active-hover-bg: rgba(22,115,209,.3);
  --main-bg: #111e2e;
  --header-border: rgba(169,183,204,.14);
  --search-bg: #0f1930;
  --search-bg-focus: #111e35;
  --search-border: #34445f;
  --search-border-hover: #4a5f7e;
  --search-focus-ring: rgba(82,179,255,.12);
  --scrollbar-thumb: #445978;
  --scrollbar-thumb-hover: #5a7191;
  --row-odd: #162437;
  --row-even: #101c2b;
  --row-hover: #223450;
  --row-selected: #17365a;
  --row-selected-hover: #1b3d64;
  --row-border: rgba(169,183,204,.07);
  --row-border-mobile: rgba(169,183,204,.12);
  --badge-bg: #2a3a54;
  --badge-border: rgba(169,183,204,.12);
  --badge-selected-bg: rgba(82,179,255,.16);
  --badge-selected-border: rgba(82,179,255,.3);
  --badge-selected-text: #d9efff;
  --positive: #75d6a4;
  --negative: #ff929e;
  --topbar-bg: linear-gradient(180deg, #1d2c47, #182640);
  --topbar-border: rgba(169,183,204,.12);
  --topbar-shadow: 0 4px 14px rgba(3,12,26,.24);
  --toggle-hover-bg: rgba(82,179,255,.12);
  --scrim-bg: rgba(0,0,0,.5);
  --drawer-shadow: 8px 0 28px rgba(3,12,26,.38);
  --focus-ring: #52b3ff;
  --chart-orange: #f76a1a;
  --chart-pink: #ff7b86;
  --chart-sky: #1d9cf0;
  --chart-blue: #0658f1;
  --chart-violet: #7e2df7;
  --chart-deep-violet: #4c2897;
  --chart-royal-blue: #1670f3;
  --chart-indigo: #627eea;
  --chart-steel-blue: #4695c3;
  --chart-orchid: #b657e1;
  --chart-light-violet: #855ee5;
  --chart-yellow: #f4c148;
}

html[data-theme="light"] {
  color-scheme: light;
  --page-bg: #f6f9fc;
  --text-primary: #172033;
  --text-strong: #0b2540;
  --text-secondary: #334b63;
  --text-muted: #53697f;
  --text-soft: #465d74;
  --text-placeholder: #53697f;
  --action-border: rgba(22,115,209,.28);
  --action-border-hover: #0f63b8;
  --action-shadow: 0 8px 20px rgba(17,51,85,.12);
  --action-shadow-hover: 0 10px 24px rgba(17,51,85,.18);
  --notice-bg: #e9f5fe;
  --notice-border: #b9d9f2;
  --notice-text: #25344a;
  --sidebar-bg: linear-gradient(180deg, #ffffff 0%, #f8fafc 45%, #f3f7fb 100%);
  --sidebar-border: #dbe4ee;
  --balance-bg: #f6f9fc;
  --balance-border: #c9dfef;
  --balance-shadow: 0 6px 16px rgba(17,51,85,.06);
  --nav-text: #3e526a;
  --nav-hover-bg: #edf5fc;
  --nav-hover-text: #102a43;
  --nav-active-bg: #e9f5fe;
  --nav-active-text: #0f63b8;
  --nav-active-hover-bg: #dcefff;
  --main-bg: #ffffff;
  --header-border: #dbe4ee;
  --search-bg: #ffffff;
  --search-bg-focus: #ffffff;
  --search-border: #c4d2e0;
  --search-border-hover: #8da2b8;
  --search-focus-ring: rgba(22,115,209,.14);
  --scrollbar-thumb: #b7c8da;
  --scrollbar-thumb-hover: #8da2b8;
  --row-odd: #ffffff;
  --row-even: #f6f9fc;
  --row-hover: #eaf3fb;
  --row-selected: #e9f5fe;
  --row-selected-hover: #dcefff;
  --row-border: #e7edf4;
  --row-border-mobile: #dbe4ee;
  --badge-bg: #edf2f7;
  --badge-border: #d5e0ea;
  --badge-selected-bg: #d8edff;
  --badge-selected-border: #9fcdf2;
  --badge-selected-text: #0f5798;
  --positive: #167a46;
  --negative: #c92a2a;
  --topbar-bg: linear-gradient(180deg, #ffffff, #f6f9fc);
  --topbar-border: #dbe4ee;
  --topbar-shadow: 0 4px 14px rgba(17,51,85,.08);
  --toggle-hover-bg: #e9f5fe;
  --scrim-bg: rgba(9,21,37,.38);
  --drawer-shadow: 8px 0 28px rgba(17,51,85,.18);
  --focus-ring: #1673d1;
  --chart-orange: #c85100;
  --chart-pink: #c4314f;
  --chart-sky: #0969aa;
  --chart-yellow: #8a5a00;
}

/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: Inter, "Segoe UI", "SF Pro Text", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--page-bg);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { background: none; border: none; color: inherit; cursor: pointer; font: inherit; }
a { color: inherit; text-decoration: none; }
input { font: inherit; color: inherit; background: none; border: none; outline: none; }

.demo-notice {
  display: flex;
  align-items: center;
  min-height: 60px;
  margin: 16px 16px 0;
  padding: 12px 16px;
  border: 1px solid var(--notice-border);
  border-radius: 8px;
  background: var(--notice-bg);
  color: var(--notice-text);
  font-size: 13px;
  line-height: 1.55;
}
@media (max-width: 991px) {
  .demo-notice { margin-top: 12px; }
}

/* === APP SHELL === */
.app-demo {
  --app-header-height: var(--header-height);
  min-width: 0;
  line-height: 1.5;
  background: var(--page-bg);
}
.app {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  height: calc(100vh - var(--app-header-height));
  height: calc(100dvh - var(--app-header-height));
  min-height: 560px;
  overflow: hidden;
  border-top: 1px solid var(--header-border);
}

/* === SIDEBAR === */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  padding: 24px 0 16px;
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 0; }

.sidebar-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px;
  margin-bottom: 22px;
}

.sidebar .logo {
  display: block;
  width: 34px;
  height: 34px;
  margin-bottom: 12px;
}
.sidebar .logo:hover { opacity: 1; }
.sidebar .logo svg { width: 100%; height: 100%; display: block; }

.app-name {
  font-size: 20px;
  font-weight: 650;
  color: var(--text-primary);
  margin-bottom: 14px;
  letter-spacing: .01em;
}

.balance-card {
  background: var(--balance-bg);
  border: 1px solid var(--balance-border);
  border-radius: 10px;
  padding: 12px 14px;
  width: 100%;
  max-width: 144px;
  text-align: center;
  box-shadow: var(--balance-shadow);
}
.balance-value {
  font-size: 20px;
  font-weight: 650;
  line-height: 1.25;
  margin-bottom: 4px;
}
.balance-value span {
  color: var(--text-soft);
  font-weight: 500;
  font-size: 14px;
  margin-right: 2px;
}
.balance-cur {
  font-size: 11px;
  color: var(--text-soft);
  font-weight: 600;
  letter-spacing: .08em;
}

/* === NAV === */
.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0 10px;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--nav-text);
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  white-space: nowrap;
}
.nav-item:hover {
  background: var(--nav-hover-bg);
  color: var(--nav-hover-text);
}
.nav-item.active {
  background: var(--nav-active-bg);
  color: var(--nav-active-text);
  box-shadow: inset 3px 0 var(--focus-ring);
}
.nav-item.active:hover {
  background: var(--nav-active-hover-bg);
}
.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.nav-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* === MAIN === */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--main-bg);
}
.asset-table {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

/* === TABLE HEADER === */
.table-header {
  display: grid;
  grid-template-columns:
    minmax(176px, 5.8fr)
    minmax(120px, 3.4fr)
    minmax(105px, 4.1fr)
    minmax(105px, 4.1fr)
    minmax(64px, 3fr)
    minmax(80px, 3.5fr)
    minmax(90px, 3.2fr)
    minmax(150px, 5fr);
  column-gap: 12px;
  align-items: center;
  min-height: 56px;
  padding: 8px 12px;
  background: var(--main-bg);
  border-bottom: 1px solid var(--header-border);
  flex-shrink: 0;
}
.th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .035em;
}
.th-right {
  text-align: right;
}
.th-center {
  text-align: center;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-input {
  width: 100%;
  min-height: 40px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-primary);
  background: var(--search-bg);
  border: 1px solid var(--search-border);
  border-radius: 8px;
  padding: 9px 12px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.search-input:hover {
  border-color: var(--search-border-hover);
}
.search-input:focus {
  background: var(--search-bg-focus);
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 3px var(--search-focus-ring);
}
.search-input::placeholder {
  color: var(--text-placeholder);
  opacity: 1;
}

/* === TABLE BODY === */
.table-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--main-bg);
}
.table-body::-webkit-scrollbar { width: 8px; }
.table-body::-webkit-scrollbar-track { background: var(--main-bg); }
.table-body::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }
.table-body::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

/* === ROW === */
.row {
  position: relative;
  display: grid;
  grid-template-columns:
    minmax(176px, 5.8fr)
    minmax(120px, 3.4fr)
    minmax(105px, 4.1fr)
    minmax(105px, 4.1fr)
    minmax(64px, 3fr)
    minmax(80px, 3.5fr)
    minmax(90px, 3.2fr)
    minmax(150px, 5fr);
  column-gap: 12px;
  align-items: center;
  min-height: 68px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--row-border);
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
.row:nth-child(odd) {
  background: var(--row-odd);
}
.row:nth-child(even) {
  background: var(--row-even);
}
.row:hover {
  background: var(--row-hover);
}
.row.selected {
  background: var(--row-selected);
  box-shadow: inset 3px 0 var(--focus-ring);
}
.row.selected:hover {
  background: var(--row-selected-hover);
}
.row-select {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* === CELLS === */
.cell {
  font-size: 15px;
  line-height: 1.35;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}
.cell-right {
  text-align: right;
}
.cell-center {
  text-align: center;
}

/* Asset cell */
.c-asset {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 4px;
}
.asset-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}
.asset-icon-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: contain;
}
.asset-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.asset-name {
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
}
.asset-badge {
  background: var(--badge-bg);
  border: 1px solid var(--badge-border);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  padding: 2px 6px;
  border-radius: 5px;
  white-space: nowrap;
}
.row.selected .asset-badge {
  background: var(--badge-selected-bg);
  border-color: var(--badge-selected-border);
  color: var(--badge-selected-text);
}

/* Balance */
.c-balance {
  color: var(--text-strong);
  font-weight: 500;
}
.c-balance.zero {
  color: var(--text-muted);
}

/* Value */
.c-value {
  color: var(--text-primary);
  font-weight: 600;
}
.c-value.zero {
  color: var(--text-muted);
  font-weight: 500;
}

/* Price */
.c-price {
  color: var(--text-secondary);
  font-weight: 500;
}

/* 24h */
.c-24h {
  font-size: 14px;
  font-weight: 600;
}
.pos,
.pos-zero {
  color: var(--positive);
}
.neg {
  color: var(--negative);
}

/* Portfolio */
.c-portfolio {
  font-size: 14px;
  color: var(--text-soft);
  font-weight: 500;
}

/* M.cap */
.c-mcap {
  color: var(--text-soft);
  font-weight: 500;
}

/* Chart */
.c-chart {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.sparkline {
  width: 100%;
  max-width: 240px;
  height: 34px;
}
.sparkline polyline {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sparkline polyline[stroke="#F76A1A" i] { stroke: var(--chart-orange); }
.sparkline polyline[stroke="#ff7b86" i] { stroke: var(--chart-pink); }
.sparkline polyline[stroke="#1D9CF0" i] { stroke: var(--chart-sky); }
.sparkline polyline[stroke="#0658F1" i] { stroke: var(--chart-blue); }
.sparkline polyline[stroke="#7E2DF7" i] { stroke: var(--chart-violet); }
.sparkline polyline[stroke="#4C2897" i] { stroke: var(--chart-deep-violet); }
.sparkline polyline[stroke="#1670F3" i] { stroke: var(--chart-royal-blue); }
.sparkline polyline[stroke="#627EEA" i] { stroke: var(--chart-indigo); }
.sparkline polyline[stroke="#4695C3" i] { stroke: var(--chart-steel-blue); }
.sparkline polyline[stroke="#B657E1" i] { stroke: var(--chart-orchid); }
.sparkline polyline[stroke="#855EE5" i] { stroke: var(--chart-light-violet); }
.sparkline polyline[stroke="#F4C148" i] { stroke: var(--chart-yellow); }

/* === TOPBAR (MOBILE) === */
.topbar {
  display: none;
  position: sticky;
  top: var(--app-header-height);
  z-index: 40;
  min-height: 60px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  box-shadow: var(--topbar-shadow);
}
.nav-toggle {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.15s;
}
.nav-toggle:hover {
  background: var(--toggle-hover-bg);
}
.nav-toggle svg {
  width: 22px;
  height: 22px;
  stroke: var(--nav-hover-text);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 650;
  color: var(--text-primary);
}
.topbar-brand svg {
  width: 26px;
  height: 26px;
}
.topbar-balance {
  margin-left: auto;
  font-size: 14px;
  color: var(--notice-text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* === SCRIM === */
.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--scrim-bg);
  z-index: 45;
  opacity: 0;
  transition: opacity 0.25s;
}
.scrim.active {
  display: block;
  opacity: 1;
}

/* === RESPONSIVE === */

/* Tablet: 992-1199px — hide M.cap and chart */
@media (max-width: 1199px) {
  .table-header, .row {
    grid-template-columns:
      minmax(170px, 6fr)
      minmax(110px, 3.6fr)
      minmax(100px, 4.4fr)
      minmax(95px, 4.4fr)
      minmax(64px, 3.2fr)
      minmax(80px, 3.8fr);
  }
  .c-mcap, .c-chart,
  .th-mcap, .th-chart {
    display: none;
  }
}

/* Mobile drawer: ≤991px */
@media (max-width: 991px) {
  .app {
    display: block;
    height: auto;
    min-height: 0;
  }
  .topbar {
    display: flex;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--app-header-height);
    bottom: 0;
    z-index: 50;
    width: min(280px, calc(100vw - 40px));
    visibility: hidden;
    transform: translateX(-105%);
    transition: transform 0.25s ease, visibility 0s linear 0.25s;
    box-shadow: var(--drawer-shadow);
  }
  .sidebar.open {
    visibility: visible;
    transform: translateX(0);
    transition-delay: 0s;
  }
  .main {
    height: auto;
    min-height: calc(100vh - var(--app-header-height) - 60px);
    min-height: calc(100dvh - var(--app-header-height) - 60px);
  }
  .table-body {
    overflow: visible;
  }
}

@media (max-width: 768px) {
  .app-demo { --app-header-height: 64px; }
}

/* Mobile cards: ≤767px */
@media (max-width: 767px) {
  .demo-notice {
    margin: 12px 12px 0;
    padding: 11px 12px;
  }
  .table-header {
    display: grid;
    grid-template-columns: 1fr;
    min-height: 68px;
    padding: 12px 14px;
  }
  .th {
    display: none;
  }
  .th-search {
    display: block;
  }
  .search-input {
    min-height: 44px;
    font-size: 16px;
  }
  .row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "asset pct"
      "balance value"
      "price chart";
    row-gap: 10px;
    column-gap: 12px;
    min-height: 0;
    padding: 16px;
    border-bottom: 1px solid var(--row-border-mobile);
  }
  .c-asset { grid-area: asset; }
  .c-24h { grid-area: pct; text-align: right; align-self: center; }
  .c-balance { grid-area: balance; }
  .c-value { grid-area: value; text-align: right; }
  .c-price { grid-area: price; }
  .c-chart { grid-area: chart; align-self: center; padding: 0; }
  .c-portfolio, .c-mcap { display: none; }
  .sparkline {
    width: 100px;
    max-width: 100px;
    height: 28px;
  }
  .asset-name {
    font-size: 16px;
  }
  .c-balance, .c-value, .c-price {
    font-size: 14px;
  }
}

/* Small mobile: ≤480px */
@media (max-width: 480px) {
  .topbar {
    gap: 9px;
    padding-inline: 10px;
  }
  .topbar-brand {
    font-size: 16px;
  }
  .topbar-balance {
    font-size: 13px;
  }
  .row {
    padding: 15px 14px;
  }
  .asset-icon,
  .asset-icon-img {
    width: 28px;
    height: 28px;
  }
  .asset-icon {
    font-size: 10px;
  }
  .c-asset {
    gap: 10px;
  }
  .asset-info {
    gap: 6px;
  }
  .asset-name {
    font-size: 15px;
  }
  .c-balance, .c-value, .c-price {
    font-size: 13.5px;
  }
  .sparkline {
    width: 84px;
    max-width: 84px;
    height: 24px;
  }
}

/* === ACCESSIBILITY === */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}
.row-select:focus-visible {
  outline-offset: -4px;
}
@media (prefers-reduced-motion: reduce) {
  .search-input,
  .nav-item,
  .nav-toggle,
  .row,
  .scrim,
  .sidebar {
    transition: none;
  }
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}
