.portfolio-stats { margin-bottom: 14px; }
.trading-accounts, .trading-positions, .owned-assets { margin-bottom: 14px; }
.portfolio-section { margin: 0 0 12px; border: 1px solid var(--line); border-radius: 13px; background: linear-gradient(155deg,rgba(18,25,36,.94),rgba(12,17,25,.94)); overflow: clip; }
.portfolio-section > summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; padding: 13px 17px; cursor: pointer; list-style: none; user-select: none; }
.portfolio-section > summary::-webkit-details-marker { display: none; }
.portfolio-section > summary:hover { background: #17202d; }
.portfolio-section > summary span { min-width: 0; }
.portfolio-section > summary b { display: block; color: #e7edf6; font-size: 14px; }
.portfolio-section > summary small { display: block; margin-top: 2px; color: #738399; font-size: 11px; }
.portfolio-section > summary i { flex: 0 0 auto; color: var(--green); font-size: 25px; font-style: normal; line-height: 1; transition: transform .2s ease; }
.portfolio-section[open] > summary { border-bottom: 1px solid var(--line); background: #141d29; }
.portfolio-section[open] > summary i { transform: rotate(90deg); }
.portfolio-section-body { padding: 12px; }
.portfolio-section-body > :last-child { margin-bottom: 0; }
.portfolio-section-body .panel { box-shadow: none; }
.secondary-stats { margin-bottom: 12px; }
.trading-positions .panel-title p { margin: 2px 0 0; font-size: 11px; }
.position-overview { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; margin-bottom:14px; }
.position-overview > div { padding:11px 13px; border:1px solid var(--line); border-radius:9px; background:#0d141d; }
.position-overview small,.position-metrics small,.position-context small { display:block; color:var(--muted); font-size:9px; letter-spacing:.06em; text-transform:uppercase; }
.position-overview b { display:block; margin-top:3px; font-size:16px; }
.position-list { display:grid; gap:10px; }
.position-card { padding:15px; border:1px solid #2a3545; border-radius:12px; background:linear-gradient(145deg,#121b27,#0c121b); }
.position-card header,.position-card header>div,.position-card footer { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.position-card header>div { justify-content:flex-start; }
.position-card h3 { margin:0; color:#f3f6fb; font-size:17px; }
.position-card header p { margin:1px 0 0; font-size:10px; }
.position-card header>strong { font-size:21px; }
.position-metrics { display:grid; grid-template-columns:repeat(6,minmax(110px,1fr)); gap:8px; margin:14px 0; }
.position-metrics>div,.position-context>div { min-width:0; padding:9px 10px; border-radius:8px; background:#0b1119; }
.position-metrics b,.position-context b { display:block; margin-top:3px; overflow:hidden; text-overflow:ellipsis; }
.position-context { display:grid; grid-template-columns:1fr 1.4fr 1fr; gap:8px; }
.position-context em { display:block; color:#657489; font-size:9px; font-style:normal; }
.position-context code { display:block; overflow:hidden; color:#657489; font-size:9px; text-overflow:ellipsis; white-space:nowrap; }
.position-card footer { justify-content:flex-end; margin-top:12px; padding-top:11px; border-top:1px solid var(--line); }
.position-card footer .secondary { padding:7px 10px; color:#b9c6d6; font-size:11px; text-decoration:none; }
table[data-sortable] th[data-sort] { cursor: pointer; user-select: none; }
table[data-sortable] th[data-sort]::after { content: " ↕"; color: #536176; }
table[data-sortable] th[data-direction="asc"]::after { content: " ↑"; color: var(--green); }
table[data-sortable] th[data-direction="desc"]::after { content: " ↓"; color: var(--green); }
.asset-dex-link { cursor: pointer; transition: background-color .15s ease, box-shadow .15s ease; }
.asset-dex-link:hover, .asset-dex-link:focus-visible { background: #152131; box-shadow: inset 3px 0 var(--green); outline: none; }
.asset-dex-link:hover td:first-child::before, .asset-dex-link:focus-visible td:first-child::before { color: var(--green); }
.wallet-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 13px 0; border-top: 1px solid var(--line); }
.wallet-row p { margin: 1px 0; font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.wallet-row small { color: #657489; }
.wallet-row mark { display: block; margin-top: 4px; white-space: normal; }
.wallet-row.muted { opacity: .68; }
.platform.bnb { background: #382f12; color: #f3ba2f; }
.platform.robinhood { background: #213413; color: #9cff49; }
.portfolio-config { margin: 14px 0; }
.portfolio-config form { display: flex; align-items: end; gap: 12px; }
.portfolio-config label { margin: 0; max-width: 390px; flex: 1; }
.portfolio-config p { font-size: 11px; margin: 10px 0 0; }
.positive { color: var(--green); }
.negative { color: var(--red); }
.market-heat { display: inline-flex; align-items: center; gap: 6px; min-width: 116px; padding: 5px 8px; border: 1px solid #2a3545; border-radius: 999px; background: #121a25; color: #9cabbc; }
.market-heat i { min-width: 15px; font-style: normal; letter-spacing: -4px; }
.market-heat b { color: inherit; font-size: 12px; }
.market-heat small { margin-left: auto; color: inherit; font-size: 8px; letter-spacing: .03em; text-transform: uppercase; }
.heat-warm { border-color: #5c4a26; background: #282012; color: #ffd06f; }
.heat-hot { border-color: #815129; background: #351d10; color: #ffad5b; box-shadow: 0 0 12px #ff8b3330; }
.heat-very-hot { border-color: #a6472d; background: #421812; color: #ff865f; box-shadow: 0 0 16px #ff633d45; }
.heat-extreme { border-color: #e45b32; background: linear-gradient(110deg,#51140e,#35180b); color: #fff0ca; box-shadow: 0 0 20px #ff5e354f; animation: market-heat-pulse 1.6s ease-in-out infinite; }
.heat-selloff { border-color: #812f42; background: #35141d; color: #ff8298; }
.heat-cooling { border-color: #394d68; background: #142034; color: #82b7ef; }
.asset-heat-extreme td { background: linear-gradient(90deg,#4b171018,transparent 72%); }
@keyframes market-heat-pulse { 50% { border-color: #ffbf55; box-shadow: 0 0 26px #ff713b80; transform: scale(1.035); } }
@media (prefers-reduced-motion: reduce) { .heat-extreme { animation: none; } }
@media (max-width: 720px) {
  .position-overview { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .position-metrics { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .position-context { grid-template-columns:1fr; }
  .wallet-row { grid-template-columns: 36px 1fr; }
  .wallet-row > strong, .wallet-row > form { grid-column: 2; }
  .portfolio-config form { display: block; }
}
@media (max-width: 620px) {
  .owned-assets .mobile-card-table[data-sortable] thead {
    display: block;
    width: 100%;
    max-width: 100%;
    margin-bottom: 10px;
    overflow: visible;
  }
  .owned-assets .mobile-card-table[data-sortable] thead tr {
    display: flex;
    width: 100%;
    max-width: 100%;
    flex-wrap: wrap;
    gap: 6px;
  }
  .owned-assets .mobile-card-table[data-sortable] th {
    max-width: 100%;
    white-space: normal;
  }
  .portfolio-section { border-radius: 12px; }
  .portfolio-section > summary { min-height: 58px; padding: 11px 13px; }
  .portfolio-section > summary b { font-size: 14px; }
  .portfolio-section > summary small { font-size: 11px; }
  .portfolio-section-body { padding: 8px; }
  .portfolio-section-body .panel { padding: 12px; }
  .wallet-row { grid-template-columns: 36px minmax(0,1fr); align-items: start; gap: 9px 11px; }
  .wallet-row > strong { font-size: 16px; }
  .wallet-row p { white-space: normal; overflow-wrap: anywhere; }
  .wallet-row form { display: inline-block; }
  .portfolio-config label { max-width: none; }
  .market-heat { min-width: 0; max-width: 100%; }
  .market-heat small { font-size: 9px; }
  .trading-positions .panel-title p { font-size: 12px; line-height: 1.45; }

  /* Labels travel with their values when the terminal reorders columns.
     Never infer a financial metric from its visual column position. */
  .owned-assets .mobile-card-table tbody { gap: 10px; }
  .owned-assets .mobile-card-table tbody tr {
    grid-template-columns: repeat(2, minmax(0,1fr));
    align-items: start;
    gap: 12px;
    padding: 14px;
  }
  .owned-assets .mobile-card-table tbody td { font-size: 12px; }
  .owned-assets .mobile-card-table tbody td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    font-size: 9px;
  }
  .owned-assets .mobile-card-table tbody td[data-label="Aktywo"] { grid-column: 1 / -1; }
  .owned-assets .mobile-card-table tbody td[data-label="Aktywo"] b { font-size: 15px; }
  table[data-sortable] .market-heat { min-height: 26px; padding: 3px 7px; gap: 4px; }
  table[data-sortable] .market-heat i { min-width: 12px; font-size: 11px; }
  table[data-sortable] .market-heat b { font-size: 11px; }
  table[data-sortable] .market-heat small { display: none; }
}
