/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f2f3f6;
  --surface-3: #e7e9ee;
  --border: #e2e4ea;
  --border-strong: #cfd3db;
  --text: #14161b;
  --text-2: #4a5060;
  --text-3: #7a8090;
  --accent: #3b5fd9;
  --accent-soft: #e7ecfc;
  --accent-ink: #ffffff;
  --pos: #13803c;
  --neg: #c52a2f;
  --pos-soft: #e3f4e8;
  --neg-soft: #fbe6e6;
  --map-gap: #e9ebf0;
  --metal: #8f97a6;
  --metal-2: #c3c8d2;
  --shadow: 0 1px 2px rgba(16, 20, 30, 0.05), 0 6px 20px rgba(16, 20, 30, 0.06);
  --shadow-lg: 0 10px 40px rgba(16, 20, 30, 0.18);
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, 'Helvetica Neue', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #0c0e12;
    --surface: #14171d;
    --surface-2: #1a1e26;
    --surface-3: #232833;
    --border: #242934;
    --border-strong: #343b48;
    --text: #e8eaf0;
    --text-2: #a6acba;
    --text-3: #727989;
    --accent: #6f8cff;
    --accent-soft: #1e2640;
    --accent-ink: #0c0e12;
    --pos: #3ccf72;
    --neg: #ff5c61;
    --pos-soft: #13261b;
    --neg-soft: #2b1517;
    --map-gap: #0c0e12;
    --metal: #6d7587;
    --metal-2: #9aa2b3;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 16px 50px rgba(0, 0, 0, 0.55);
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0c0e12;
  --surface: #14171d;
  --surface-2: #1a1e26;
  --surface-3: #232833;
  --border: #242934;
  --border-strong: #343b48;
  --text: #e8eaf0;
  --text-2: #a6acba;
  --text-3: #727989;
  --accent: #6f8cff;
  --accent-soft: #1e2640;
  --accent-ink: #0c0e12;
  --pos: #3ccf72;
  --neg: #ff5c61;
  --pos-soft: #13261b;
  --neg-soft: #2b1517;
  --map-gap: #0c0e12;
  --metal: #6d7587;
  --metal-2: #9aa2b3;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 16px 50px rgba(0, 0, 0, 0.55);
}

/* Colour-blind friendly scheme: blue for gains, orange for losses */
:root[data-scheme='colorblind'] {
  --pos: #1f63c9;
  --neg: #c2530e;
  --pos-soft: #e4edfb;
  --neg-soft: #fcebdf;
}
@media (prefers-color-scheme: dark) {
  :root[data-scheme='colorblind']:not([data-theme='light']) {
    --pos: #5c9cff;
    --neg: #ff8f45;
    --pos-soft: #16233b;
    --neg-soft: #2e1d12;
  }
}
:root[data-scheme='colorblind'][data-theme='dark'] {
  --pos: #5c9cff;
  --neg: #ff8f45;
  --pos-soft: #16233b;
  --neg-soft: #2e1d12;
}

/* ---------- base ---------- */
[hidden] {
  display: none !important;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
.num {
  font-variant-numeric: tabular-nums;
}
.pos {
  color: var(--pos);
}
.neg {
  color: var(--neg);
}
.muted {
  color: var(--text-3);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover {
  background: var(--surface-2);
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn.primary:hover {
  filter: brightness(1.08);
}
.btn.danger {
  color: var(--neg);
}
.btn.danger.solid {
  background: var(--neg);
  border-color: var(--neg);
  color: #fff;
}
.btn.ghost {
  border-color: transparent;
  background: transparent;
}
.btn.ghost:hover {
  background: var(--surface-2);
}
.btn.icon {
  width: 34px;
  padding: 0;
}
.btn.sm {
  height: 28px;
  padding: 0 10px;
  font-size: 13px;
}
.btn.sm.icon {
  width: 28px;
}
.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.field > span {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
}
.field small {
  color: var(--text-3);
  font-size: 12px;
}
.input,
.select {
  height: 38px;
  width: 100%;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus,
.select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
.select.compact {
  height: 32px;
  font-size: 13px;
}
.row {
  display: flex;
  gap: 12px;
}
.row > * {
  flex: 1;
}
.input-group {
  display: flex;
}
.input-group .input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.input-group .select {
  width: 96px;
  flex: none;
  border-left: 0;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* segmented control */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.seg::-webkit-scrollbar {
  display: none;
}
.seg button {
  border: 0;
  background: transparent;
  height: 28px;
  padding: 0 11px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  flex: none;
}
.seg button:hover {
  color: var(--text);
}
.seg button[aria-pressed='true'] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.seg button.dim {
  color: var(--text-3);
}
.seg button.dim[aria-pressed='true'] {
  color: var(--text-2);
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 56px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 750;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.brand svg {
  width: 26px;
  height: 26px;
}
.portfolio-picker {
  display: flex;
  align-items: center;
  gap: 4px;
}
.portfolio-picker .select {
  height: 34px;
  width: auto;
  max-width: 220px;
  font-weight: 600;
}
.tabs {
  display: flex;
  gap: 2px;
  margin-left: 6px;
}
.tabs a {
  white-space: nowrap;
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--text-2);
  text-decoration: none;
  font-weight: 600;
}
.tabs a:hover {
  color: var(--text);
  background: var(--surface-2);
}
.tabs a[aria-current='page'] {
  color: var(--text);
  background: var(--surface-3);
}
.spacer {
  flex: 1;
}
.user-chip {
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-weight: 550;
}
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
}

/* ---------- layout ---------- */
.page {
  max-width: 1600px;
  margin: 0 auto;
  padding: 18px 20px 40px;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-bottom: 14px;
}
.toolbar .label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.updated {
  font-size: 12.5px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
}
.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 0;
}
.card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}
.side {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- heat map ---------- */
.map-card {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.map-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 2px 4px 0;
}
.map-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.map-title h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}
.map-title .sub {
  color: var(--text-3);
  font-size: 13px;
}
.legend {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-3);
}
.legend-bar {
  display: flex;
  gap: 2px;
}
.legend-bar span {
  width: 26px;
  height: 12px;
  border-radius: 3px;
}
.treemap-wrap {
  position: relative;
  height: calc(100vh - 210px);
  min-height: 420px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--map-gap);
}
.treemap {
  position: absolute;
  inset: 0;
}
.tile {
  position: absolute;
  z-index: 1;
  border-radius: 5px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  padding: 2px 4px;
  user-select: none;
}
.tile:hover,
.tile:focus-visible {
  filter: brightness(1.15) saturate(1.05);
  z-index: 2;
}
.tile:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: -2px;
}
.tile .t-label {
  font-weight: 750;
  letter-spacing: -0.01em;
  line-height: 1.05;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile .t-line {
  font-weight: 600;
  line-height: 1.2;
  opacity: 0.92;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.tile .t-line.small {
  opacity: 0.75;
  font-weight: 500;
}
.tile.light-text {
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
}
.tile.dark-text {
  color: #14161b;
}
.group-label {
  position: absolute;
  z-index: 1;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.group-label .gl-val {
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0;
}
.group-frame {
  position: absolute;
  z-index: 0;
  border-radius: 8px;
  background: var(--surface-2);
}

/* gains/losses split header */
.split-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 12px;
  padding: 0 4px;
}
.split-head .side-label {
  display: flex;
  flex-direction: column;
}
.split-head .side-label.right {
  align-items: flex-end;
  text-align: right;
}
.split-head .side-label b {
  white-space: nowrap;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.split-head .side-label span {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
}
.split-bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  gap: 2px;
  margin: 0 4px;
}
.split-bar i {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: flex-grow 0.5s ease;
}
.split-net {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  padding-bottom: 2px;
}
.split-net b {
  display: block;
  white-space: nowrap;
  font-size: 14px;
  color: var(--text);
}

.map-empty {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--text-2);
  padding: 20px;
}
.map-empty h3 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 20px;
}
.map-empty p {
  margin: 0 0 18px;
  max-width: 420px;
}
.map-empty .actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* loading shimmer bar */
.progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  overflow: hidden;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.2s;
}
.progress.on {
  opacity: 1;
}
.progress::after {
  content: '';
  position: absolute;
  inset: 0;
  width: 35%;
  background: var(--accent);
  border-radius: 2px;
  animation: slide 1.1s ease-in-out infinite;
}
@keyframes slide {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(300%);
  }
}

/* ---------- tooltip ---------- */
.tooltip {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  min-width: 230px;
  max-width: 300px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  font-size: 12.5px;
}
.tt-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}
.tt-name {
  font-weight: 700;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tt-sym {
  color: var(--text-3);
  white-space: nowrap;
  font-size: 12px;
}
.tt-big {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 6px 0 8px;
  font-variant-numeric: tabular-nums;
}
.tt-big b {
  font-size: 19px;
  letter-spacing: -0.01em;
}
.tt-big span {
  font-weight: 650;
}
.tt-rows {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 14px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.tt-rows dt {
  color: var(--text-3);
}
.tt-rows dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 550;
}
.tt-note {
  margin-top: 8px;
  color: var(--text-3);
  font-size: 11.5px;
}

/* ---------- balance scale ---------- */
.balance {
  padding-bottom: 14px;
}
.balance-readout {
  text-align: center;
  padding: 6px 16px 0;
}
.balance-readout .net {
  font-size: 30px;
  font-weight: 750;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.balance-readout .pct-pill {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 10px;
  border-radius: 99px;
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.pct-pill.pos {
  background: var(--pos-soft);
}
.pct-pill.neg {
  background: var(--neg-soft);
}
.pct-pill.flat {
  background: var(--surface-2);
  color: var(--text-2);
}
.balance-svg {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 2px;
}
.scale-metal {
  fill: var(--metal);
}
.scale-metal-2 {
  fill: var(--metal-2);
}
.scale-string {
  stroke: var(--metal);
  stroke-width: 1.2;
}
.scale-dish {
  fill: var(--surface-3);
  stroke: var(--metal);
  stroke-width: 1.2;
}
.scale-tick {
  stroke: var(--text-3);
  stroke-width: 1.2;
  stroke-linecap: round;
}
.scale-dial {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 8;
  stroke-linecap: round;
}
.scale-dial-neg {
  fill: none;
  stroke: var(--neg);
  stroke-width: 8;
  stroke-linecap: round;
  opacity: 0.45;
}
.scale-dial-pos {
  fill: none;
  stroke: var(--pos);
  stroke-width: 8;
  stroke-linecap: round;
  opacity: 0.45;
}
.scale-needle {
  stroke: var(--text);
  stroke-width: 2.5;
  stroke-linecap: round;
}
.scale-needle-tip {
  fill: var(--text);
}
.scale-sign {
  font-size: 20px;
  font-weight: 800;
  text-anchor: middle;
}
.scale-brick-label {
  font-size: 9.5px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}
.scale-brick {
  stroke: var(--surface);
  stroke-width: 1.5;
}
.balance-sides {
  display: flex;
  justify-content: space-between;
  padding: 0 16px;
  margin-top: -4px;
}
.balance-sides div {
  display: flex;
  flex-direction: column;
}
.balance-sides div:last-child {
  text-align: right;
}
.balance-sides span {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
}
.balance-sides b {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.balance-flow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 12px 16px 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  flex-wrap: wrap;
  text-align: center;
}
.balance-flow b {
  color: var(--text);
}
.balance-flow .arrow {
  color: var(--text-3);
}

/* ---------- movers ---------- */
.movers {
  padding-bottom: 8px;
}
.movers-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}
.mover {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  padding: 7px 16px;
  cursor: pointer;
}
.mover:hover {
  background: var(--surface-2);
}
.mover .m-name {
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mover .m-val {
  text-align: right;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.mover .m-bar {
  grid-column: 1 / -1;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}
.mover .m-bar i {
  display: block;
  height: 100%;
  border-radius: 2px;
}
.mover .m-sub {
  font-size: 12px;
  color: var(--text-3);
}
.mover .m-pct {
  font-size: 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.movers-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 16px;
}
.movers-empty {
  padding: 12px 16px;
  color: var(--text-3);
}

/* ---------- banners ---------- */
.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  font-size: 13px;
}
.banner.warn {
  border-color: color-mix(in srgb, #e3a008 50%, var(--border));
  background: color-mix(in srgb, #e3a008 10%, var(--surface));
}

/* ---------- holdings table ---------- */
.holdings-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.holdings-head h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.kpis {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.kpi span {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
}
.kpi b {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}
.table-card {
  overflow-x: auto;
}
table.holdings {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.holdings th,
.holdings td {
  padding: 11px 14px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.holdings th:first-child,
.holdings td:first-child {
  text-align: left;
}
.holdings th {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  background: var(--surface);
}
.holdings th:hover {
  color: var(--text);
}
.holdings th.sorted::after {
  content: ' ↓';
}
.holdings th.sorted.asc::after {
  content: ' ↑';
}
.holdings th.nosort {
  cursor: default;
}
.holdings tbody tr:hover {
  background: var(--surface-2);
}
.holdings tbody tr:last-child td {
  border-bottom: 0;
}
.asset-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}
.swatch {
  width: 10px;
  height: 30px;
  border-radius: 3px;
  flex: none;
}
.asset-name {
  font-weight: 650;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.asset-sub {
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  gap: 6px;
  align-items: center;
}
.badge {
  display: inline-block;
  padding: 0 6px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface-3);
  color: var(--text-2);
  line-height: 17px;
}
.badge.err {
  background: var(--neg-soft);
  color: var(--neg);
}
.cell-sub {
  display: block;
  font-size: 12px;
  color: var(--text-3);
}
.row-actions {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
}
.empty-table {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-2);
}

/* ---------- dialogs ---------- */
dialog.modal {
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop {
  background: rgba(8, 10, 14, 0.5);
  backdrop-filter: blur(2px);
}
dialog.modal.small {
  width: min(420px, calc(100vw - 32px));
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 6px;
}
.modal-head h2 {
  margin: 0;
  font-size: 18px;
}
.modal-body {
  padding: 10px 20px 4px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 18px 20px 20px;
}
.modal-foot .left {
  margin-right: auto;
}
.form-error {
  color: var(--neg);
  background: var(--neg-soft);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.hint {
  font-size: 12.5px;
  color: var(--text-3);
  margin: 0;
}
.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  font-size: 12.5px;
}
.link-btn:hover {
  text-decoration: underline;
}

/* search autocomplete */
.search {
  position: relative;
}
.search-results {
  list-style: none;
  margin: 4px 0 0;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  max-height: 280px;
  overflow-y: auto;
}
.search-results li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 10px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.search-results li[aria-selected='true'],
.search-results li:hover {
  background: var(--accent-soft);
}
.search-results .sr-sym {
  font-weight: 700;
}
.search-results .sr-name {
  grid-column: 1;
  font-size: 12.5px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-results .sr-meta {
  grid-row: 1 / 3;
  grid-column: 2;
  align-self: center;
  font-size: 11.5px;
  color: var(--text-3);
  text-align: right;
}
.search-results .sr-empty {
  display: block;
  color: var(--text-3);
  cursor: default;
}
.picked {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.picked .p-main {
  flex: 1;
  min-width: 0;
}
.picked .p-sym {
  font-weight: 750;
}
.picked .p-name {
  font-size: 12.5px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.picked .p-price {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}
.picked .p-price small {
  display: block;
  font-weight: 500;
  color: var(--text-3);
}
.kind-seg {
  width: 100%;
}
.kind-seg button {
  flex: 1;
}

/* ---------- toasts ---------- */
.toasts {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-weight: 550;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease;
}
.toast.error {
  background: var(--neg);
  color: #fff;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------- popover menu ---------- */
.popover {
  position: absolute;
  z-index: 50;
  min-width: 260px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- auth ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}
.auth-art {
  position: relative;
  overflow: hidden;
  background: #0f1116;
  color: #e8eaf0;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.auth-art .brand {
  color: #fff;
}
.auth-art h1 {
  font-size: 40px;
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin: 0 0 14px;
  max-width: 520px;
}
.auth-art p {
  color: #a6acba;
  font-size: 16px;
  max-width: 460px;
  margin: 0;
}
.auth-mosaic {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(4, 56px);
  gap: 4px;
  margin: 36px 0;
  max-width: 560px;
}
.auth-mosaic span {
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-weight: 750;
  font-size: 13px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.auth-mosaic span small {
  font-weight: 600;
  opacity: 0.85;
  font-size: 11px;
}
.auth-form-wrap {
  display: grid;
  place-items: center;
  padding: 32px 20px;
}
.auth-form {
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-form h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.02em;
}
.auth-form .sub {
  margin: -8px 0 6px;
  color: var(--text-2);
}
.auth-form .btn {
  height: 40px;
}
.auth-switch {
  text-align: center;
  color: var(--text-2);
  font-size: 13.5px;
}

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .user-chip .uname {
    display: none;
  }
}
@media (max-width: 1100px) {
  .map-layout {
    grid-template-columns: 1fr;
  }
  .side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  .treemap-wrap {
    height: 62vh;
  }
}
@media (max-width: 760px) {
  .topbar {
    padding: 0 12px;
    gap: 8px;
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .brand span {
    display: none;
  }
  .user-chip {
    display: none;
  }
  .portfolio-picker .select {
    max-width: 40vw;
  }
  .topbar > .btn.icon,
  .lang-btn {
    width: 32px;
    padding: 0;
  }
  .lang-btn svg {
    display: none;
  }
  .seg button {
    padding: 0 7px;
    font-size: 12.5px;
  }
  .updated {
    display: none;
  }
  .tabs {
    order: 5;
    width: 100%;
    margin: 0;
  }
  .tabs a {
    flex: 1;
    text-align: center;
  }
  .page {
    padding: 12px 12px 32px;
  }
  .side {
    grid-template-columns: 1fr;
  }
  .treemap-wrap {
    height: 58vh;
    min-height: 340px;
  }
  .auth {
    grid-template-columns: 1fr;
  }
  .auth-art {
    padding: 28px 20px;
  }
  .auth-art h1 {
    font-size: 28px;
  }
  .auth-mosaic {
    grid-template-rows: repeat(4, 40px);
    margin: 20px 0 0;
  }
  .auth-art .foot {
    display: none;
  }
  .row {
    flex-direction: column;
  }
  .split-head {
    gap: 6px;
  }
  .split-head .side-label b {
    font-size: 14px;
  }
  .split-net b {
    font-size: 12.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- tile motion: boxes morph between periods and views ---------- */
.treemap .tile {
  transition: left 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), top 0.5s cubic-bezier(0.2, 0.8, 0.2, 1),
    width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), height 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), background-color 0.5s,
    opacity 0.35s, filter 0.12s;
}
.treemap.no-anim .tile {
  transition: filter 0.12s, opacity 0.35s;
}
.auth-mosaic {
  grid-auto-flow: dense;
}

/* ---------- language switch ---------- */
.lang-btn {
  gap: 5px;
  padding: 0 9px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.auth {
  position: relative;
}
.auth-lang {
  position: absolute;
  top: 16px;
  right: 16px;
}
