:root {
  color-scheme: dark;
  --bg: #080b10;
  --panel: #10161f;
  --panel-soft: #141c27;
  --line: #253244;
  --text: #eef4ff;
  --muted: #8b9bb0;
  --accent: #40d7ff;
  --accent-2: #66f0b1;
  --danger: #ff6b8a;
  --warm: #ffbf5f;
  --cool: #78a6ff;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 10% 0%, rgba(64, 215, 255, 0.14), transparent 28rem),
    linear-gradient(135deg, #080b10 0%, #0c1118 48%, #06080c 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button {
  font: inherit;
}

.dashboard-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  height: 100vh;
  height: 100dvh;
  width: min(1800px, 100%);
  margin: 0 auto;
  overflow: hidden;
  padding: 20px 28px 18px;
}

.topbar,
.control-row,
.main-grid,
.etf-board {
  width: 100%;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 32px;
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
}

.perspective-copy {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.status-strip {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.status-strip span,
.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.status-strip strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 0;
}

.sector-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.sector-tab {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 22, 31, 0.78);
  color: #b9c9dc;
  padding: 9px 12px;
  white-space: nowrap;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.sector-tab[aria-selected="true"] {
  border-color: rgba(64, 215, 255, 0.8);
  background: rgba(64, 215, 255, 0.13);
  color: var(--text);
  box-shadow: 0 0 26px rgba(64, 215, 255, 0.13);
}

.view-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 22, 31, 0.78);
  padding: 4px;
}

.view-switch button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #b9c9dc;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  padding: 8px 12px;
  white-space: nowrap;
}

.view-switch button[aria-selected="true"] {
  background: rgba(64, 215, 255, 0.15);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(64, 215, 255, 0.5);
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  min-height: 0;
}

.map-panel,
.etf-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 22, 31, 0.84);
  box-shadow: var(--shadow);
}

.map-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 22px;
  padding: 14px 18px 5px;
}

.panel-head.compact {
  padding-bottom: 9px;
}

.map-notes {
  display: grid;
  justify-items: end;
  min-width: 0;
  gap: 8px;
}

#sector-summary {
  max-width: min(760px, 58vw);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: right;
  margin-bottom: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.etf-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.chart {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  padding: 10px;
}

.chain-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--stage-count, 3), minmax(0, 1fr));
  gap: 12px;
  height: 100%;
  min-height: 0;
}

.chain-lane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(37, 50, 68, 0.72);
  border-radius: 8px;
  background: rgba(8, 11, 16, 0.42);
  padding: 10px;
}

.lane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(37, 50, 68, 0.72);
  padding-bottom: 8px;
  margin-bottom: 9px;
}

.lane-head span,
.lane-head b {
  display: block;
  color: var(--text);
  font-size: 14px;
  font-weight: 850;
}

.lane-head strong {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lane-head b {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 24px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--stage-color) 16%, transparent);
  color: var(--stage-color);
}

.lane-nodes {
  display: flex;
  flex-direction: column;
  gap: 9px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 2px;
  scrollbar-color: rgba(139, 155, 176, 0.42) transparent;
  scrollbar-width: thin;
}

.map-node {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 88px;
  min-width: 0;
  flex-shrink: 0;
  border: 1px solid rgba(37, 50, 68, 0.95);
  border-left-width: 4px;
  border-left-color: var(--stage-color);
  border-radius: 8px;
  background: rgba(16, 22, 31, 0.94);
  padding: 10px 11px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease,
    transform 160ms ease;
}

.map-node:hover {
  border-color: rgba(64, 215, 255, 0.6);
  transform: translateY(-1px);
}

.map-node.highlighted,
.etf-card.active {
  border-color: rgba(64, 215, 255, 0.95);
  box-shadow: 0 0 24px rgba(64, 215, 255, 0.2);
  transform: translateY(-1px);
}

.map-node.muted {
  opacity: 0.36;
}

.node-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.node-main strong {
  color: var(--text);
  font-size: 14px;
  line-height: 1.25;
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.node-role {
  margin-top: 6px;
  color: #c4d2e3;
  font-size: 12px;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  text-overflow: ellipsis;
}

.node-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.etf-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.etf-board {
  margin-top: 0;
}

.etf-board .panel-head {
  align-items: end;
}

.etf-help {
  max-width: 460px;
  margin-bottom: 0;
  text-align: right;
}

.etf-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 360px));
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 14px 12px;
  scrollbar-color: rgba(139, 155, 176, 0.42) transparent;
  scrollbar-width: thin;
}

.etf-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    background 160ms ease;
}

.etf-card:hover,
.etf-card.active {
  border-color: rgba(102, 240, 177, 0.8);
  background: rgba(102, 240, 177, 0.1);
  transform: translateY(-1px);
}

.etf-card:focus-visible {
  outline: 2px solid rgba(64, 215, 255, 0.75);
  outline-offset: 2px;
}

.etf-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.etf-head > div:first-child {
  min-width: 0;
}

.etf-name {
  color: var(--text);
  font-size: 17px;
  font-weight: 850;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.etf-market {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.return {
  color: var(--accent-2);
  font-weight: 850;
  white-space: nowrap;
}

.return.negative {
  color: var(--danger);
}

.etf-card p {
  margin: 7px 0 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  border: 1px solid rgba(139, 155, 176, 0.28);
  border-radius: 999px;
  color: #b7c5d7;
  font-size: 11px;
  padding: 4px 7px;
}

@media (max-height: 820px) {
  .dashboard-shell {
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: 6px;
    padding: 10px 24px;
  }

  .eyebrow {
    margin-bottom: 4px;
    font-size: 10px;
  }

  h1 {
    font-size: 26px;
  }

  h2 {
    font-size: 18px;
  }



  .sector-tab {
    padding: 6px 9px;
  }

  .view-switch button {
    padding: 6px 9px;
  }

  .panel-head {
    padding: 8px 12px 3px;
  }

  .panel-head.compact {
    padding-bottom: 4px;
  }

  .perspective-copy {
    margin-top: 5px;
  }

  .chart {
    padding: 6px;
  }

  .chain-board {
    gap: 8px;
  }

  .chain-lane {
    padding: 8px;
  }

  .lane-head {
    margin-bottom: 6px;
    padding-bottom: 6px;
  }

  .lane-nodes {
    gap: 6px;
  }

  .map-node {
    min-height: 66px;
    padding: 7px 9px;
  }

  .node-main strong {
    font-size: 13px;
  }

  .node-role {
    margin-top: 3px;
    font-size: 11px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .node-meta {
    font-size: 10px;
  }

  .etf-list {
    grid-auto-rows: auto;
    gap: 8px;
    padding: 4px 12px 8px;
  }

  .etf-card {
    min-width: 0;
    padding: 8px 10px;
  }

  .etf-name {
    font-size: 14px;
  }

  .etf-card p {
    margin: 4px 0 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tag-row {
    display: none;
  }
}

@media (max-width: 900px) {
  .topbar,
  .control-row {
    align-items: stretch;
    flex-direction: column;
  }

  .status-strip {
    min-width: 0;
  }

  .main-grid {
    grid-template-columns: 1fr;
  }

  .chart {
    min-height: auto;
  }

  .chain-board {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .etf-list {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}

@media (max-width: 720px) {
  .dashboard-shell {
    padding: 16px;
  }

  h1 {
    font-size: 28px;
  }

  .panel-head {
    flex-direction: column;
  }

  .map-notes,
  #sector-summary,
  .etf-help {
    justify-items: start;
    text-align: left;
    white-space: normal;
  }
}

/* Modal and Information Guide styles */
.map-panel .panel-head {
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  transition: background-color 160ms ease;
}

.map-panel .panel-head:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.info-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  color: rgba(64, 215, 255, 0.85);
  background: rgba(64, 215, 255, 0.12);
  border: 1px solid rgba(64, 215, 255, 0.25);
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: all 150ms ease;
}

.map-panel .panel-head:hover .info-badge {
  background: rgba(64, 215, 255, 0.25);
  border-color: rgba(64, 215, 255, 0.6);
  box-shadow: 0 0 8px rgba(64, 215, 255, 0.3);
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(8, 12, 18, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #0f1724;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  width: 90%;
  max-width: 620px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5), 0 0 40px rgba(64, 215, 255, 0.05);
  transform: scale(0.95) translateY(10px);
  transition: transform 240ms cubic-bezier(0.16, 1, 0.3, 1);
  padding: 30px;
}

.modal-overlay.active .modal-content {
  transform: scale(1) translateY(0);
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #8b9bb4;
  font-size: 20px;
  font-weight: 300;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease;
  line-height: 1;
  padding: 0;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.modal-body .eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(64, 215, 255, 0.9);
}

.modal-body h2 {
  margin: -8px 0 0 0;
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.modal-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 18px;
}

.modal-section h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #c4d2e3;
  letter-spacing: -0.01em;
}

.modal-section p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: #a0aebf;
}

.modal-steps-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.modal-step-card {
  display: flex;
  gap: 12px;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  padding: 12px 14px;
  align-items: flex-start;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.modal-step-card:hover {
  background: rgba(64, 215, 255, 0.02);
  border-color: rgba(64, 215, 255, 0.15);
}

.modal-step-num {
  background: rgba(64, 215, 255, 0.1);
  color: rgba(64, 215, 255, 0.95);
  border: 1px solid rgba(64, 215, 255, 0.25);
  font-size: 11px;
  font-weight: 800;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-step-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.modal-step-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.modal-step-desc {
  font-size: 12px;
  line-height: 1.5;
  color: #909fb3;
}

/* SVG Connection Lines overlay styling */
.connections-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  overflow: visible;
}

.connection-path {
  fill: none;
  stroke-linecap: round;
  transition: opacity 250ms ease;
  pointer-events: stroke;
  cursor: pointer;
}

.connection-path.strong,
.connection-path.weak {
  stroke: rgba(64, 215, 255, 0.95);
  stroke-width: 2.6;
  animation: pulseStrong 2.0s ease-in-out infinite;
}

@keyframes pulseStrong {
  0% {
    stroke-opacity: 0.7;
    filter: drop-shadow(0 0 2px rgba(64, 215, 255, 0.4));
  }
  50% {
    stroke-opacity: 1.0;
    filter: drop-shadow(0 0 6px rgba(64, 215, 255, 0.85));
  }
  100% {
    stroke-opacity: 0.7;
    filter: drop-shadow(0 0 2px rgba(64, 215, 255, 0.4));
  }
}

/* Custom Tooltip for Connections */
.connection-tooltip {
  position: fixed;
  left: -9999px;
  top: -9999px;
  z-index: 1000;
  background: rgba(12, 18, 28, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(64, 215, 255, 0.4);
  border-radius: 10px;
  padding: 14px 16px;
  width: max-content;
  max-width: 320px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6), 0 0 20px rgba(64, 215, 255, 0.15);
  pointer-events: auto;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 150ms cubic-bezier(0.16, 1, 0.3, 1), transform 150ms cubic-bezier(0.16, 1, 0.3, 1);
  color: #fff;
  font-family: inherit;
}

.tooltip-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 13.5px;
  color: #fff;
  margin-bottom: 6px;
}

.tooltip-node {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.tooltip-arrow {
  color: var(--accent);
}

.tooltip-badge-row {
  margin-bottom: 8px;
}

.tooltip-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.tooltip-badge.strong-badge {
  background: rgba(64, 215, 255, 0.15);
  color: #5ce1ff;
  border: 1px solid rgba(64, 215, 255, 0.3);
}

.tooltip-badge.weak-badge {
  background: rgba(102, 240, 177, 0.15);
  color: #7ef2c1;
  border: 1px solid rgba(102, 240, 177, 0.3);
}

.tooltip-note {
  font-size: 12.5px;
  line-height: 1.5;
  color: #b9c9dc;
  margin-bottom: 10px;
}

.tooltip-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 8px;
  display: flex;
  justify-content: flex-end;
}

.tooltip-link {
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 800;
  transition: color 150ms ease;
}

.tooltip-link:hover {
  color: #fff;
  text-decoration: underline;
}
