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

:root {
  --navy:   #1a2e4a;
  --blue:   #2563eb;
  --blue-h: #1d4ed8;
  --bg:     #f1f5f9;
  --card:   #ffffff;
  --border: #e2e8f0;
  --text:   #1e293b;
  --muted:  #64748b;
  --green:  #16a34a;
  --red:    #dc2626;
  --row-h:  #eff6ff;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: var(--navy);
  padding: 20px 32px;
  display: flex;
  align-items: center;
  gap: 12px;
}
header h1 {
  color: #fff;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
header .subtitle {
  color: #94a3b8;
  font-size: 0.8rem;
  margin-top: 2px;
}

/* ── Search bar ── */
.search-wrap {
  background: var(--navy);
  padding: 0 32px 24px;
}
.search-bar {
  display: flex;
  gap: 10px;
  max-width: 480px;
}
.search-bar input {
  flex: 1;
  padding: 10px 14px;
  font-size: 1rem;
  border: 2px solid transparent;
  border-radius: 8px;
  outline: none;
  background: rgba(255,255,255,0.12);
  color: #fff;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: background 0.2s, border-color 0.2s;
}
.search-bar input::placeholder { color: #94a3b8; text-transform: none; }
.search-bar input:focus {
  background: rgba(255,255,255,0.2);
  border-color: var(--blue);
}
.search-bar button {
  padding: 10px 22px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.search-bar button:hover { background: var(--blue-h); }
.search-bar button:disabled { opacity: 0.55; cursor: not-allowed; }

/* ── Main content ── */
main { padding: 24px 32px; max-width: 1400px; margin: 0 auto; }

/* ── Status / error messages ── */
.status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.status.error { color: var(--red); }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── ETF info bar ── */
.etf-info {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 32px;
  margin-bottom: 16px;
  padding: 14px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.etf-info .badge {
  font-size: 0.8rem;
  color: var(--muted);
}
.etf-info .badge strong {
  display: block;
  font-size: 1rem;
  color: var(--text);
  font-weight: 700;
}

/* ── Table container ── */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

/* ── Table header ── */
thead th {
  background: var(--navy);
  color: #cbd5e1;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 16px;
  text-align: right;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
  position: sticky;
  top: 0;
  z-index: 1;
}
thead th:first-child,
thead th:nth-child(2) { text-align: left; }
thead th:hover { background: #243d5e; }
thead th.sort-asc,
thead th.sort-desc { color: #fff; }

.sort-icon {
  display: inline-block;
  margin-left: 5px;
  opacity: 0.4;
  font-size: 0.7rem;
}
thead th.sort-asc  .sort-icon,
thead th.sort-desc .sort-icon { opacity: 1; color: #60a5fa; }

/* ── Table body ── */
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--row-h); }

tbody td {
  padding: 11px 16px;
  text-align: right;
  vertical-align: middle;
  white-space: nowrap;
}
tbody td:first-child,
tbody td:nth-child(2) { text-align: left; }

/* Code cell */
.cell-code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--blue);
}

/* Name cell — allow wrap */
.cell-name {
  white-space: normal;
  min-width: 160px;
  max-width: 240px;
  color: var(--text);
}

/* N/A values */
.na { color: #94a3b8; }

/* Weight bar */
.weight-cell { min-width: 110px; }
.weight-bar-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}
.weight-bar {
  height: 6px;
  background: var(--blue);
  border-radius: 3px;
  min-width: 2px;
  opacity: 0.7;
}
.weight-val { min-width: 46px; text-align: right; }

/* ── Responsive tweak ── */
@media (max-width: 768px) {
  header, .search-wrap, main { padding-left: 16px; padding-right: 16px; }
}
