:root {
  --bg: #0d0e12;
  --panel: rgba(26, 28, 33, 0.88);
  --sunken: #15171b;
  --line: rgba(255, 255, 255, 0.08);
  --text: rgba(241, 243, 247, 0.94);
  --muted: rgba(241, 243, 247, 0.62);
  --accent: #ffb000;
  --accent-2: #ff7a45;
  --accent-soft: rgba(255, 176, 0, 0.14);
  --ok: #52c41a;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "Consolas", "SFMono-Regular", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  overflow-x: hidden;
  background:
    radial-gradient(1100px 420px at 18% 0%, rgba(255, 176, 0, 0.24), transparent 54%),
    radial-gradient(900px 320px at 100% 0%, rgba(255, 122, 69, 0.18), transparent 48%),
    linear-gradient(180deg, #0b0c10 0%, #121419 54%, #0e1014 100%);
}

.page {
  max-width: 1380px;
  margin: 0 auto;
  padding: 24px;
}

.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 24px;
  padding: 18px 24px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 8px 0 0;
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hero-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.logo-badge {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  filter: drop-shadow(0 6px 14px rgba(255, 176, 0, 0.22));
}

.hero h1 {
  margin: 0;
  font-size: 42px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.hero-brand > div:last-child {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-lookup-form {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 92px;
  gap: 10px;
  align-items: center;
  margin-left: auto;
}

.panel-head p,
.disclaimer-card p,
.footer-bar {
  color: var(--muted);
}

.disclaimer-card {
  padding: 2px 0 2px 18px;
  border-left: 4px solid var(--accent);
}

.disclaimer-card h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.disclaimer-card p {
  margin: 0 0 5px;
  line-height: 1.6;
  font-size: 12px;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.rank-grid,
.portfolio-column {
  display: grid;
  gap: 14px;
}

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

.rank-panel,
.portfolio-panel,
.lookup {
  padding: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-head-tight {
  margin-bottom: 10px;
}

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

.panel-head p {
  margin: 6px 0 0;
  font-size: 13px;
}

.link,
.hero-lookup-form button,
#dialog-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 176, 0, 0.22);
  background: var(--accent-soft);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}

.link:hover,
.hero-lookup-form button:hover,
#dialog-close:hover {
  transform: translateY(-1px);
  background: rgba(255, 176, 0, 0.24);
}

.table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-weight: 600;
}

td.num {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}

.rank-wrap {
  overflow-x: auto;
  overflow-y: hidden;
}

.rank-wrap tbody tr:last-child td,
.holdings-table tbody tr:last-child td {
  border-bottom: 0;
}

.portfolio-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.portfolio-metrics > div {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
}

.portfolio-metrics span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.portfolio-metrics strong {
  font-size: 26px;
  color: var(--ok);
  font-variant-numeric: tabular-nums;
}

.mini-chart {
  position: relative;
  min-height: 132px;
  margin-bottom: 12px;
  padding: 8px 12px 0;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background:
    linear-gradient(180deg, rgba(255, 176, 0, 0.09), rgba(255, 255, 255, 0.015)),
    var(--sunken);
}

.chart-legend {
  display: flex;
  gap: 14px;
  align-items: center;
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 11px;
}

.legend-swatch {
  display: inline-block;
  width: 20px;
  height: 3px;
  margin-right: 6px;
  vertical-align: middle;
  border-radius: 999px;
}

.portfolio-swatch {
  background: var(--accent-2);
  height: 4px;
}

.benchmark-swatch {
  background: #5a8dff;
}

.trend-svg {
  width: 100%;
  height: 132px;
  display: block;
}

.trend-area {
  fill: rgba(255, 176, 0, 0.14);
}

.trend-line {
  fill: none;
  stroke: var(--accent-2);
  stroke-width: 3;
}

.benchmark-line {
  stroke: #5a8dff;
  stroke-width: 1.7;
}

.trend-dot {
  fill: var(--accent-2);
}

.trend-label {
  fill: var(--muted);
  font-size: 9px;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
}

.holdings-wrap {
  max-height: 178px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.holdings-table {
  min-width: 0;
}

.rank-panel table {
  table-layout: auto;
}

.rank-panel th:nth-child(1),
.rank-panel td:nth-child(1) {
  width: 10%;
}

.rank-panel th:nth-child(2),
.rank-panel td:nth-child(2) {
  width: 30%;
}

.rank-panel th:nth-child(3),
.rank-panel td:nth-child(3) {
  width: 32%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-panel th:nth-child(4),
.rank-panel td:nth-child(4) {
  width: 28%;
}

.hero-lookup-form input {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 15px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.hero-lookup-form input::placeholder {
  color: rgba(241, 243, 247, 0.42);
}

.dialog-card {
  width: min(820px, 92vw);
  min-width: min(820px, 92vw);
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #101319;
  color: var(--text);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.dialog-head h3 {
  margin: 0;
}

.lookup-result {
  display: grid;
  gap: 14px;
}

.lookup-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.lookup-meta strong {
  font-size: 18px;
}

.lookup-meta span {
  color: var(--muted);
  font-size: 13px;
}

.lookup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.lookup-card {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.lookup-card h4 {
  margin: 0 0 12px;
  font-size: 16px;
}

.lookup-card dl {
  margin: 0;
  display: grid;
  gap: 10px;
}

.lookup-card dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}

.lookup-card dt {
  color: var(--muted);
}

.lookup-card dd {
  margin: 0;
  font-family: var(--mono);
}

.lookup-empty,
.empty {
  color: var(--muted);
  text-align: center;
}

.footer-bar {
  margin: 18px 0 0;
  padding: 10px 4px 0;
  font-size: 14px;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.footer-bar a {
  color: var(--muted);
  text-decoration: none;
}

.footer-bar a:hover {
  color: var(--text);
  text-decoration: underline;
}

@media (max-width: 1240px) {
  .dashboard,
  .hero {
    grid-template-columns: 1fr;
  }

  .dashboard {
    gap: 16px;
  }

  .hero-copy {
    flex-wrap: wrap;
  }

  .hero-lookup-form {
    width: 100%;
    margin-left: 0;
  }

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

@media (max-width: 860px) {
  .page {
    max-width: 100%;
    padding: 12px;
  }

  .panel {
    border-radius: 14px;
  }

  .hero {
    padding: 14px;
    gap: 14px;
  }

  .hero-copy {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .hero-brand {
    gap: 10px;
  }

  .logo-badge {
    width: 44px;
    height: 44px;
    font-size: 34px;
  }

  .hero h1 {
    font-size: 40px;
  }

  .eyebrow {
    margin-top: 4px;
    font-size: 12px;
    letter-spacing: 0.04em;
  }

  .hero-lookup-form {
    width: 100%;
    grid-template-columns: 1fr 90px;
    margin-left: 0;
  }

  .hero-lookup-form input {
    padding: 12px 14px;
    font-size: 15px;
  }

  .hero-lookup-form button {
    padding: 10px 12px;
  }

  .disclaimer-card {
    padding: 0 0 0 12px;
  }

  .disclaimer-card h2 {
    font-size: 15px;
    margin-bottom: 6px;
  }

  .disclaimer-card p {
    font-size: 11px;
    line-height: 1.55;
  }

  .rank-panel,
  .portfolio-panel,
  .lookup {
    padding: 14px;
  }

  .portfolio-panel .panel-head {
    flex-wrap: wrap;
    gap: 8px;
  }

  .portfolio-panel .link {
    font-size: 12px;
    line-height: 1.1;
    padding: 8px 10px;
    max-width: 148px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .panel h2 {
    font-size: 20px;
  }

  th,
  td {
    padding: 8px 6px;
    font-size: 12px;
  }

  .rank-panel table {
    table-layout: fixed;
  }

  .rank-panel th,
  .rank-panel td {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .portfolio-metrics strong {
    font-size: 22px;
  }

  .dialog-card {
    width: min(96vw, 680px);
    min-width: 0;
    padding: 14px;
  }

  .lookup-card {
    padding: 12px;
  }

  .lookup-card h4 {
    font-size: 15px;
  }
}

@media (max-width: 720px) {
  .hero h1 {
    font-size: 34px;
  }

  .hero-lookup-form {
    grid-template-columns: 1fr 78px;
  }

  .lookup-grid,
  .portfolio-metrics {
    grid-template-columns: 1fr;
  }

  .portfolio-metrics > div {
    padding: 10px 12px;
  }

  .chart-legend {
    font-size: 10px;
    gap: 10px;
  }

  .holdings-wrap {
    max-height: 162px;
  }

  .rank-panel th:nth-child(1),
  .rank-panel td:nth-child(1) {
    width: 10%;
  }

  .rank-panel th:nth-child(2),
  .rank-panel td:nth-child(2) {
    width: 30%;
  }

  .rank-panel th:nth-child(3),
  .rank-panel td:nth-child(3) {
    width: 30%;
  }

  .rank-panel th:nth-child(4),
  .rank-panel td:nth-child(4) {
    width: 30%;
  }

  .holdings-table th:nth-child(4),
  .holdings-table td:nth-child(4),
  .holdings-table th:nth-child(5),
  .holdings-table td:nth-child(5) {
    display: none;
  }

  .portfolio-panel .link {
    max-width: 132px;
  }

  .footer-bar {
    font-size: 12px;
    gap: 10px;
  }
}

@media (max-width: 420px) {
  .page {
    padding: 10px;
  }

  .hero {
    padding: 12px;
  }

  .hero-brand {
    align-items: flex-start;
  }

  .hero h1 {
    font-size: 30px;
  }

  .hero-lookup-form {
    grid-template-columns: 1fr;
  }

  .hero-lookup-form button {
    width: 100%;
  }

  .mini-chart {
    min-height: 120px;
    padding: 8px 10px 0;
  }

  .trend-svg {
    height: 120px;
  }

  .rank-panel,
  .portfolio-panel {
    padding: 12px;
  }

  .rank-panel th,
  .rank-panel td,
  .holdings-table th,
  .holdings-table td {
    font-size: 11px;
    padding: 7px 5px;
  }
}
