/* ==========================================================================
   Valen — Portfolio dashboard
   Sizes and colours are measured from the reference screenshots (1536px wide).
   ========================================================================== */

:root {
  /* Surfaces */
  --background: #090B10;
  --panel: #15171B;
  --panel-secondary: #1E2226;
  --table-head: #1A1E22;
  --row-hover: #1A1C21;
  --nav-active: #24282C;
  --chip: #22262C;
  --border: #24262C;
  --border-strong: #2A2E33;
  --border-hover: #30343A;

  /* Text */
  --text: #F7F8F9;
  --text-muted: #CACCD0;
  --text-secondary: #8E949D;
  --text-faint: #6C737C;
  --text-divider: #4D545B;

  /* Semantic */
  --green: #56D364;
  --red: #FF6166;
  --blue: #7AB0FF;
  --orange: #F7931A; /* Bitcoin */
  --green-bg: #1E2D24;
  --red-bg: #322025;
  --blue-bg: #222937;

  /* Chart bars */
  --bar-green: #2B5434;
  --bar-red: #612F34;
  --bar-flat: #373B41;
  --bar-highlight: #24262A;

  /* Layout */
  --gap: 8px;
  --gutter: 20px; /* left and right edge of the toolbar, the cards and Activity */
  --radius: 8px;
  --header-height: 64px;
  --upper-height: 306px;

  /* Type scale — width-fitted to the reference text at 1536px. */
  --font: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --fs-base: 12.5px;   /* tables, labels, tabs, badges */
  --fs-small: 11px;    /* token quantities, chart dates */
  --fs-nav: 13.5px;    /* header navigation and controls */
  --fs-title: 14.5px;  /* panel titles, card values */
  --fs-figure: 21px;   /* headline PNL and win rate */
}

/* ---------- Base ---------- */

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

html {
  background: var(--background);
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 18px;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h2,
dl,
dd {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
  flex: none;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.is-pos { color: var(--green); }
.is-neg { color: var(--red); }

/* A figure that is still loading ("--") or cannot be given ("N/A"). */
.is-loading,
.is-unavailable {
  color: var(--text-faint);
}

.is-loading {
  animation: loading-pulse 1.4s ease-in-out infinite;
}

@keyframes loading-pulse {
  50% { opacity: 0.45; }
}

@media (prefers-reduced-motion: reduce) {
  .is-loading {
    animation: none;
  }
}

* {
  scrollbar-width: thin;
  scrollbar-color: #2E3238 transparent;
}

/* ---------- App shell ---------- */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-height: 640px;
}

.main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: var(--gap) var(--gutter);
}

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  min-width: 0;
}

/* Shared structure of the three top cards: a fixed-height header, then the
   card's own content underneath. */
.card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
}

.card-title {
  font-size: var(--fs-title);
  line-height: 20px;
  font-weight: 500;
}

/* ---------- Header ---------- */

.header {
  flex: none;
  display: flex;
  align-items: center;
  height: var(--header-height);
  padding: 0 20px 0 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: 17px;
  border-radius: 6px;
}

/* The logo keeps its own proportions at the height of the wordmark. */
.brand-mark {
  width: auto;
  height: 28px;
  object-fit: contain;
}

.brand-name {
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
  letter-spacing: 0.07em;
  color: #FFFFFF;
}

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

.nav-item {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius);
  font-size: var(--fs-nav);
  color: var(--text-secondary);
  white-space: nowrap;
  transition: color 0.12s ease, background-color 0.12s ease;
}

.nav-item:hover {
  color: var(--text);
}

.nav-item.is-active {
  background: var(--nav-active);
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

/* BTC and SOL prices share one bordered control, split by a divider. */
.market,
.connect {
  display: inline-flex;
  align-items: center;
  height: 32px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--fs-nav);
  white-space: nowrap;
}

.market-price {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  padding: 0 12px;
}

.market-price + .market-price {
  border-left: 1px solid var(--border);
}

/* Each price in its asset's colour (a loading or unavailable one stays grey). */
.market-price--btc { color: var(--orange); }
.market-price--sol { color: var(--green); }

.balance-icon--round {
  border-radius: 50%;
}

.connect {
  gap: 8px;
  padding: 0 12px;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.connect svg {
  color: var(--text-secondary);
}

/* The connected wallet app's icon: the same 16px slot as the generic icon. */
.connect-provider {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  object-fit: contain;
}

.connect:hover {
  background: var(--panel-secondary);
  border-color: var(--border-hover);
}

/* ---------- Wallet bar (wallet lookup, viewed wallet, timeframe) ---------- */

.wallet-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px var(--gutter) 4px;
}

.wallet-divider {
  width: 1px;
  height: 20px;
  margin: 0 4px;
  background: var(--border-strong);
}

.wallet-id {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wallet-address {
  font-size: var(--fs-title);
}

/* Shown next to the address while a wallet other than the signed-in one is on display. */
.wallet-viewing {
  margin-left: 4px;
  padding: 0 8px;
  background: var(--chip);
  border-radius: 6px;
  font-size: 12px;
  line-height: 24px;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color 0.12s ease;
}

.wallet-viewing:hover {
  color: var(--text);
}

/* Solscan icon link (wallet bar and Activity rows). */
.solscan-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: var(--text-faint);
  transition: color 0.12s ease;
}

.solscan-link:hover {
  color: var(--text-muted);
}

.wallet-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 240px;
  height: 32px;
  padding: 0 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-faint);
  transition: border-color 0.12s ease;
}

.wallet-search:focus-within {
  border-color: var(--border-hover);
}

.wallet-search input {
  flex: 1;
  min-width: 0;
  padding: 0;
  background: none;
  border: 0;
  outline: 0;
  font: inherit;
  font-size: var(--fs-nav);
  color: var(--text);
}

.wallet-search input::placeholder {
  color: var(--text-faint);
  opacity: 1;
}

.wallet-search input::-webkit-search-cancel-button {
  display: none;
}

.wallet-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* Segmented timeframe switch. */
.periods {
  display: inline-flex;
  height: 32px;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--border);
}

.period {
  min-width: 42px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: var(--fs-nav);
  color: var(--text-secondary);
  transition: color 0.12s ease;
}

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

.period.is-active {
  background: var(--chip);
  border-color: #3A3F45;
  color: var(--text);
}

.refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  transition: color 0.12s ease, background-color 0.12s ease, border-color 0.12s ease;
}

.refresh:hover {
  background: var(--panel-secondary);
  border-color: var(--border-hover);
  color: var(--text);
}

/* The icon turns for as long as a refresh is in progress. */
.refresh.is-spinning svg {
  animation: refresh-spin 0.5s linear infinite;
}

@keyframes refresh-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .refresh.is-spinning svg {
    animation: none;
  }
}

/* ---------- Upper row ---------- */

.upper {
  flex: none;
  display: grid;
  /* Portfolio 421 / Profit & Loss 661 / Analytics 421 px at the 1536px
     reference width (~28% / 44% / 28%). */
  grid-template-columns: minmax(0, 421fr) minmax(0, 661fr) minmax(0, 421fr);
  gap: var(--gap);
  height: var(--upper-height);
}

/* ---------- Portfolio ---------- */

/* Vertical positions follow the reference card: Total Value, the Tradable
   Balance box, a separator, then three summary rows. */
.portfolio-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 21px 16px 16px;
}

.portfolio-total-label {
  font-size: var(--fs-nav);
  line-height: 20px;
  font-weight: 400;
  color: var(--text-secondary);
}

.portfolio-total-value {
  font-size: var(--fs-figure);
  line-height: 32px;
  white-space: nowrap;
}

/* Tradable Balance: label on the left, SOL | USDC on the right.
   The box and the rows below sit 3px wider than the text column, as in the reference. */
.tradable {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 40px;
  margin: 15px -3px 0;
  padding: 0 16px 0 14px;
  background: var(--panel-secondary);
  border: 1px solid var(--nav-active);
  border-radius: var(--radius);
  font-size: var(--fs-nav);
}

.tradable-label {
  font-weight: 400;
  color: var(--text-secondary);
  white-space: nowrap;
}

.tradable-balances {
  display: flex;
  align-items: center;
}

.tradable-balance {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 18px;
  padding: 0 12px;
}

.tradable-balance:last-child {
  padding-right: 0;
}

.tradable-balance + .tradable-balance {
  border-left: 1px solid var(--border-hover);
}

/* Performance summary under a separator. One set of rows per timeframe;
   only the active one is displayed. */
.portfolio-rows {
  flex: none;
  margin: 18px -3px 0;
  padding-top: 11px;
  border-top: 1px solid var(--border);
}

.portfolio-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 30px;
  padding-left: 3px;
  font-size: var(--fs-nav);
}

.portfolio-row dt {
  font-weight: 400;
  color: var(--text-secondary);
}

/* ---------- Profit & Loss ---------- */

/* One chart per timeframe; only the active one is displayed. */
.pnl-chart {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 22px 16px;
}

/* Scroll container and the canvas inside it. They only differ in size for
   long timeframes (see .pnl-chart--scroll). */
.pnl-scroll {
  flex: 1;
  min-height: 0;
  display: flex;
}

.pnl-canvas {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Long timeframes (1Y): bars keep a readable width and the chart scrolls
   sideways instead of squashing 365 bars into the panel. */
.pnl-chart--scroll {
  padding-right: 16px;
  padding-bottom: 6px;
}

.pnl-chart--scroll .pnl-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 10px; /* room for the scrollbar */
}

.pnl-chart--scroll .pnl-canvas {
  flex: none;
  box-sizing: content-box;
  width: calc(var(--bar-count) * 12px);
  padding-right: 14px; /* keeps the last date label inside */
}

.pnl-plot {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
}

/* A column is the hover target for one bar; the slot inside it is what lights up. */
.pnl-col {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
}

.pnl-slot {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  max-width: 36px; /* keeps bars slim when a timeframe has few of them */
  border-radius: 3px 3px 0 0;
}

.pnl-col.is-active .pnl-slot {
  background: var(--bar-highlight);
}

.pnl-bar {
  width: 74%;
  min-height: 7px;
  max-height: calc(100% - 2px);
  border-radius: 2px 2px 0 0;
  /* Solid at the top, fading into the panel towards the baseline. */
  background: linear-gradient(to bottom, var(--bar) 0%, var(--bar) 45%, transparent 100%);
}

.pnl-bar--short {
  background: linear-gradient(to bottom, var(--bar) 0%, var(--bar) 55%, color-mix(in srgb, var(--bar) 45%, transparent) 100%);
}

.pnl-bar--pos { --bar: var(--bar-green); }
.pnl-bar--neg { --bar: var(--bar-red); }
.pnl-bar--flat { --bar: var(--bar-flat); }

.pnl-axis {
  flex: none;
  display: flex;
  margin-top: 16px;
}

.pnl-tick {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 16px;
}

.pnl-tick span {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--fs-small);
  line-height: 16px;
  font-weight: 400;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Shown in place of the bars while there is nothing to draw. */
.pnl-message {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 24px;
  font-weight: 400;
  color: var(--text-secondary);
  text-align: center;
}

.pnl-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  padding: 7px 12px;
  background: var(--panel-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  white-space: nowrap;
  pointer-events: none;
}

.pnl-tooltip-value {
  line-height: 16px;
  color: var(--text-muted);
}

.pnl-tooltip[data-tone='pos'] .pnl-tooltip-value { color: var(--green); }
.pnl-tooltip[data-tone='neg'] .pnl-tooltip-value { color: var(--red); }

.pnl-tooltip-date {
  font-size: var(--fs-small);
  line-height: 16px;
  font-weight: 400;
  color: var(--text-secondary);
}

/* ---------- Analytics ---------- */

/* One body per timeframe; only the active one is displayed. */
.analytics-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 16px 16px;
}

.stat-cards {
  flex: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}

.stat-card {
  min-width: 0;
  height: 80px;
  padding: 8px 12px 12px;
  background: var(--panel-secondary);
  border-radius: var(--radius);
}

.stat-card-label {
  line-height: 20px;
  font-weight: 400;
  color: var(--text-muted);
}

.stat-card-value {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-title);
  line-height: 20px;
  white-space: nowrap;
}

.stat-card-sub {
  line-height: 20px;
  font-weight: 400;
  color: var(--text-secondary);
}

.stat-rows {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 8px;
}

.stat-row {
  flex: 1;
  min-height: 29px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 6px;
  border-bottom: 1px solid var(--border);
  line-height: 18px;
}

.stat-row:last-child {
  border-bottom: 0;
}

.stat-row dt {
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
}

.stat-row dd {
  text-align: right;
  white-space: nowrap;
}

.stat-sep {
  margin: 0 3px;
  font-weight: 400;
  color: var(--text-divider);
}

/* ---------- Token (icon + name) ---------- */

.token {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.token-icon {
  width: 29px;
  height: 29px;
  padding: 1px;
  background: #0D1116;
  border: 1px solid #3B4147;
  border-radius: 5px;
  object-fit: cover;
}

/* Initials, for a token whose image could not be loaded. */
.token-icon--fallback {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-secondary);
  font-size: 10px;
  line-height: 1;
  color: var(--text-secondary);
}

.token-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Lower panel: Activity ---------- */

.lower {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Tab-style section header: a single, always-active tab on the left,
   compact controls on the right. */
.section-tabs {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 42px;
  padding: 0 14px 0 10px;
  border-bottom: 1px solid var(--border);
}

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

/* Dust / Spam: a toggle for a kind of transaction that is hidden by default.
   Not pressed = hidden (eye-off, muted). Pressed = shown (eye, brighter). */
.visibility-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 8px;
  background: var(--panel-secondary);
  border: 1px solid #282C30;
  border-radius: 6px;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: color 0.12s ease, border-color 0.12s ease;
}

.visibility-toggle svg {
  color: var(--text-faint);
  transition: color 0.12s ease;
}

.visibility-toggle:hover {
  border-color: #33383E;
  color: var(--text-muted);
}

.visibility-toggle[aria-pressed='true'] {
  color: var(--text-muted);
}

.visibility-toggle[aria-pressed='true'] svg {
  color: #AEB3BA;
}

.visibility-toggle .icon-eye,
.visibility-toggle[aria-pressed='true'] .icon-eye-off {
  display: none;
}

.visibility-toggle[aria-pressed='true'] .icon-eye {
  display: block;
}

.section-tab {
  display: inline-flex;
  align-items: center;
  height: 42px;
  padding: 0 12px;
  border-bottom: 1px solid var(--text);
  font-size: inherit;
  font-weight: 500;
  white-space: nowrap;
}

.table-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

/* ---------- Table ---------- */

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.table th,
.table td {
  padding: 0 16px;
  text-align: left;
  white-space: nowrap;
}

.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 32px;
  background: var(--table-head);
  border-bottom: 1px solid var(--border);
  font-weight: 400;
  color: var(--text-secondary);
}

.table td {
  border-bottom: 1px solid var(--border);
  transition: background-color 0.08s ease;
}

.table tbody tr:hover td {
  background: var(--row-hover);
}

/* Activity: 46px rows, Age | Token | Type | Value | Amount */
.table--activity td {
  height: 46px;
}

.table--activity .col-age { width: 236px; }
.table--activity .col-token { width: 22%; }
.table--activity .col-type { width: 26%; }
.table--activity .col-value { width: 17%; }
.table--activity .col-details { width: 56px; }

/* A value that is not known is shown as a dash, never as $0. */
.table .is-unknown {
  color: var(--text-faint);
}

/* Age: absolute date/time, then relative age. */
.age {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.age-date {
  color: var(--text-secondary);
}

.age-sep {
  color: var(--text-divider);
}

.age-relative {
  color: var(--text-muted);
}

/* Solscan link at the end of each row. */
.table .cell-details {
  padding-right: 12px;
  text-align: right;
}

/* Shown in place of the rows: loading, unavailable, or nothing passes the filters. */
.table .table-empty td,
.table .table-empty:hover td {
  height: 92px;
  background: none;
  font-weight: 400;
  color: var(--text-secondary);
  text-align: center;
}

/* Transaction type */

.tx-type {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
}

.badge--buy {
  background: var(--green-bg);
  color: var(--green);
}

.badge--sell {
  background: var(--red-bg);
  color: var(--red);
}

.badge--transfer {
  height: 18px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--blue-bg);
  color: var(--blue);
}

.tx-party {
  color: var(--text-muted);
}

.tx-party-label {
  font-weight: 400;
  color: var(--text-secondary);
}

.tx-address {
  transition: color 0.12s ease;
}

.tx-address:hover {
  color: var(--text);
  text-decoration: underline;
}

/* Column-header filter button ("Type" + funnel). */
.th-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  margin: 0 -6px;
  padding: 0 6px;
  border-radius: 6px;
  font-weight: 400;
  color: var(--text-secondary);
  transition: color 0.12s ease, background-color 0.12s ease;
}

.th-filter:hover,
.th-filter[aria-expanded='true'] {
  background: var(--chip);
  color: var(--text-muted);
}

/* A filter other than "All" is applied. */
.th-filter.is-filtered {
  color: var(--text);
}

.th-filter.is-filtered svg {
  fill: currentColor;
}

/* ---------- Overlays: dropdown menu and message popover ---------- */

.menu,
.popover {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10;
  background: var(--panel-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.menu {
  min-width: 136px;
  padding: 4px;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border-radius: 6px;
  color: var(--text-muted);
  text-align: left;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: #282C31;
  color: var(--text);
  outline: 0;
}

.menu-item[aria-checked='true'] {
  color: var(--text);
}

.menu-check {
  visibility: hidden;
  color: var(--text-secondary);
}

.menu-item[aria-checked='true'] .menu-check {
  visibility: visible;
}

/* Account menu in the header: which wallet is signed in, and Disconnect. */
.account-menu {
  width: 248px;
}

.account-menu-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 4px;
  padding: 6px 8px 8px;
  border-bottom: 1px solid var(--border-strong);
}

.account-menu-address {
  font-size: var(--fs-small);
  line-height: 15px;
  font-weight: 400;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.popover {
  padding: 6px 10px;
  line-height: 18px;
  color: var(--text-muted);
  white-space: nowrap;
  pointer-events: none;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Tablet: Portfolio + Analytics side by side, the chart on its own row below.
   Page scrolls. */
@media (max-width: 1180px) {
  .app {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .upper {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    height: auto;
  }

  .upper > .panel {
    height: var(--upper-height);
  }

  .pnl {
    grid-column: 1 / -1;
    order: 1;
  }

  .lower {
    flex: none;
    overflow: visible;
  }

  .table-scroll {
    overflow-x: auto;
    overflow-y: visible;
  }

  .table tr:last-child td {
    border-bottom: 0;
  }
}

/* Small tablet / phone: the header and wallet bar become two rows each. */
@media (max-width: 760px) {
  .header {
    flex-wrap: wrap;
    height: auto;
    padding: 12px 12px 4px;
    row-gap: 5px;
  }

  /* Row 1: brand + Connect Wallet. Row 2: nav + balances. */
  .header-actions {
    display: contents;
  }

  .header::after {
    content: '';
    order: 3;
    flex-basis: 100%;
  }

  .brand { order: 1; margin-right: auto; }
  .connect { order: 2; }
  .nav { order: 4; margin-right: auto; }
  .market { order: 5; }

  /* Row 1: wallet + timeframe. Row 2: search. */
  :root {
    --gutter: 12px;
  }

  .wallet-bar {
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 14px var(--gutter) 2px;
  }

  .wallet-search {
    order: 1;
    flex-basis: 100%;
  }

  .wallet-divider {
    display: none;
  }
}

/* Phone: everything stacks. */
@media (max-width: 720px) {
  :root {
    --fs-base: 13.5px;
    --fs-small: 12px;
    --fs-nav: 14px;
  }

  .upper {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Source order again: Portfolio, Profit & Loss, Analytics. */
  .pnl {
    order: 0;
  }

  .upper > .portfolio,
  .upper > .analytics {
    height: auto;
  }

  .stat-row {
    flex: none;
    height: 36px;
  }

  .table th,
  .table td {
    padding: 0 12px;
  }

  /* Scrolls sideways only if the viewport is narrower than this. */
  .table--activity {
    min-width: 760px;
  }

  .table--activity .col-age { width: 214px; }
  .table--activity .col-token { width: 16%; }
  .table--activity .col-type { width: 31%; }
  .table--activity .col-value { width: 13%; }
  .table--activity .col-details { width: 44px; }
}

/* Narrow phones: relative age and sender/recipient move onto a second line
   to keep the Activity table as narrow as its five columns allow. */
@media (max-width: 620px) {
  .table th,
  .table td {
    padding: 0 5px;
  }

  .table th:first-child,
  .table td:first-child {
    padding-left: 12px;
  }

  .table .cell-details {
    padding-right: 6px;
  }

  .table--activity {
    min-width: 452px;
  }

  .table--activity td {
    padding-top: 7px;
    padding-bottom: 7px;
    line-height: 16px;
  }

  .table--activity .col-age { width: 118px; }
  .table--activity .col-token { width: 20%; }
  .table--activity .col-type { width: 19%; }
  .table--activity .col-value { width: 17%; }
  .table--activity .col-details { width: 32px; }

  .token {
    gap: 6px;
  }

  .table--activity .token-icon {
    width: 26px;
    height: 26px;
  }

  .age,
  .tx-type {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .age-date {
    font-size: 11px;
  }

  .tx-party {
    font-size: var(--fs-small);
  }

  /* The badge already says Received / Sent. */
  .age-sep,
  .tx-party-label {
    display: none;
  }
}

@media (max-width: 520px) {
  .upper > .pnl {
    height: auto;
  }

  .pnl-chart {
    flex: none;
    height: 220px;
    padding: 16px 12px 14px;
  }

  .pnl-tick span {
    font-size: 11px;
  }

  /* Wallet and timeframe stay on one row. */
  .wallet-bar {
    column-gap: 8px;
  }

  .period {
    min-width: 0;
    padding: 0 9px;
  }
}
