:root {
  --bg-0: #070c14;
  --bg-1: #0d1624;
  --bg-2: #132439;
  --surface-1: rgba(16, 26, 41, 0.88);
  --surface-2: rgba(21, 34, 52, 0.92);
  --surface-3: rgba(10, 18, 31, 0.78);
  --text-1: #e7eef8;
  --text-2: #a8bad0;
  --text-3: #7f93ab;
  --accent: #22d3a6;
  --accent-2: #5ab2ff;
  --accent-3: #f5be66;
  --danger: #ff7a7a;
  --ok: #3ed8ab;
  --warn: #f5be66;
  --edge: rgba(136, 162, 192, 0.25);
  --edge-strong: rgba(136, 162, 192, 0.42);
  --shadow-soft: 0 18px 48px rgba(0, 0, 0, 0.36);
  --shadow-strong: 0 24px 64px rgba(0, 0, 0, 0.5);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --mono: "IBM Plex Sans", "Segoe UI", sans-serif;
  --display: "Space Grotesk", "Arial", sans-serif;
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--mono);
  color: var(--text-1);
  background:
    radial-gradient(1200px 600px at 12% -20%, rgba(34, 211, 166, 0.2), transparent 60%),
    radial-gradient(1200px 600px at 100% 10%, rgba(90, 178, 255, 0.2), transparent 58%),
    linear-gradient(160deg, var(--bg-0) 0%, var(--bg-1) 48%, var(--bg-2) 100%);
  min-height: 100vh;
  overflow-x: auto;
  color-scheme: dark;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(circle at center, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0) 80%);
  pointer-events: none;
  z-index: 0;
}

.orb {
  position: fixed;
  width: 440px;
  height: 440px;
  border-radius: 50%;
  filter: blur(24px);
  opacity: 0.45;
  z-index: 0;
  pointer-events: none;
}

.orb-left {
  background: radial-gradient(circle, rgba(34, 211, 166, 0.55), rgba(34, 211, 166, 0));
  top: -140px;
  left: -120px;
}

.orb-right {
  background: radial-gradient(circle, rgba(90, 178, 255, 0.55), rgba(90, 178, 255, 0));
  bottom: -160px;
  right: -140px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 22px 36px 16px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(8, 14, 24, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(136, 162, 192, 0.18);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 5px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  border: 1px solid rgba(90, 178, 255, 0.45);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(90, 178, 255, 0.35);
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.35));
}

.brand-title {
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-sub {
  font-size: 0.84rem;
  color: var(--text-2);
}

.top-actions {
  display: flex;
  gap: 12px;
}

.btn {
  border: 1px solid transparent;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #021428;
  padding: 10px 18px;
  border-radius: 999px;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(12, 31, 56, 0.45);
  transition: transform 0.18s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(12, 31, 56, 0.52);
  filter: saturate(1.05);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.58;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn:focus-visible,
.chip:focus-visible {
  outline: 2px solid rgba(90, 178, 255, 0.8);
  outline-offset: 2px;
}

.btn.ghost {
  background: rgba(125, 147, 171, 0.1);
  color: var(--text-1);
  border: 1px solid rgba(125, 147, 171, 0.32);
  box-shadow: none;
}

.btn.ghost:hover {
  background: rgba(125, 147, 171, 0.16);
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 24px;
  padding: 22px 36px 56px;
  position: relative;
  z-index: 1;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  position: relative;
  background: linear-gradient(180deg, rgba(21, 34, 52, 0.94), rgba(13, 22, 36, 0.92));
  padding: 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--edge);
  overflow: hidden;
  animation: rise 0.42s ease both;
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.04);
  pointer-events: none;
}

.panel .card:nth-child(2) {
  animation-delay: 0.04s;
}

.panel .card:nth-child(3) {
  animation-delay: 0.08s;
}

.card h2 {
  font-family: var(--display);
  margin: 0 0 8px;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.muted {
  color: var(--text-2);
  margin: 0 0 14px;
  font-size: 0.9rem;
}

.file-input {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(34, 211, 166, 0.12);
  border: 1px dashed rgba(34, 211, 166, 0.5);
  color: var(--text-1);
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 12px;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.file-input:hover {
  background: rgba(34, 211, 166, 0.16);
  border-color: rgba(34, 211, 166, 0.72);
}

.input-block {
  margin-bottom: 12px;
}

.label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin-bottom: 6px;
  color: var(--text-3);
}

select,
input[type="text"],
input[type="search"],
input[type="file"],
input#ancestry-input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(125, 147, 171, 0.3);
  background: rgba(6, 12, 20, 0.52);
  color: var(--text-1);
  padding: 10px 12px;
  font-family: var(--mono);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

input::placeholder {
  color: rgba(168, 186, 208, 0.7);
}

select:focus,
input[type="text"]:focus,
input[type="search"]:focus,
input#ancestry-input:focus {
  outline: none;
  border-color: rgba(90, 178, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(90, 178, 255, 0.2);
  background: rgba(7, 14, 23, 0.72);
}

.file-input input {
  display: none;
}

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

.meta-grid > div {
  background: rgba(8, 14, 23, 0.45);
  border: 1px solid rgba(125, 147, 171, 0.22);
  border-radius: 10px;
  padding: 10px;
  min-width: 0;
}

.meta-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-3);
}

.meta-value {
  display: block;
  min-width: 0;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#sample-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#search-input {
  border-radius: 999px;
  padding: 10px 16px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border-radius: 999px;
  padding: 6px 12px;
  border: 1px solid rgba(125, 147, 171, 0.34);
  background: rgba(10, 18, 30, 0.62);
  color: var(--text-2);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.18s ease;
}

.chip:hover {
  color: var(--text-1);
  border-color: rgba(125, 147, 171, 0.52);
}

.chip.active {
  background: linear-gradient(120deg, rgba(90, 178, 255, 0.35), rgba(34, 211, 166, 0.24));
  color: var(--text-1);
  border-color: rgba(90, 178, 255, 0.62);
}

.selection-actions {
  display: flex;
  gap: 10px;
  margin: 14px 0;
}

.report-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}

.report-item {
  border: 1px solid rgba(125, 147, 171, 0.22);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  background: rgba(8, 14, 23, 0.5);
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.report-item:hover {
  background: rgba(12, 22, 35, 0.76);
  border-color: rgba(90, 178, 255, 0.36);
  transform: translateY(-1px);
}

.report-item input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.report-title {
  font-weight: 600;
  color: var(--text-1);
}

.report-meta {
  font-size: 0.8rem;
  color: var(--text-3);
}

.content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.guidance-card {
  position: relative;
  background: linear-gradient(145deg, rgba(14, 24, 38, 0.93), rgba(10, 18, 29, 0.92));
  border: 1px solid rgba(90, 178, 255, 0.24);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 16px 16px 16px 18px;
  overflow: hidden;
  animation: rise 0.42s ease both;
}

.guidance-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
}

.guidance-card h3 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 1.02rem;
}

.guidance-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text-2);
}

.guidance-list li {
  margin: 6px 0;
}

.summary-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--edge);
  box-shadow: var(--shadow-soft);
  animation: rise 0.42s ease both;
  animation-delay: 0.03s;
}

.summary-item {
  border: 1px solid rgba(125, 147, 171, 0.22);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(8, 14, 23, 0.46);
}

.summary-item span {
  color: var(--text-3);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.summary-item strong {
  display: block;
  margin-top: 6px;
  font-size: 1.1rem;
  color: var(--text-1);
}

.run-status {
  display: none;
  background: var(--surface-1);
  border-radius: var(--radius);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow-soft);
  padding: 16px;
}

.run-title {
  font-family: var(--display);
  font-weight: 600;
  margin-bottom: 8px;
}

.run-sub {
  margin-top: 8px;
  color: var(--text-2);
  font-size: 0.85rem;
}

.run-bar {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: rgba(125, 147, 171, 0.22);
  overflow: hidden;
}

.run-bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--accent-3));
  transition: width 0.25s ease;
}

body.loading .run-status {
  display: block;
}

#results {
  display: grid;
  gap: 14px;
}

.report-card {
  background: linear-gradient(180deg, rgba(20, 32, 48, 0.95), rgba(11, 19, 31, 0.94));
  border-radius: var(--radius);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow-soft);
  padding: 20px;
  animation: rise 0.42s ease both;
  min-width: 0;
  overflow: hidden;
}

.report-card:nth-child(2) {
  animation-delay: 0.03s;
}

.report-card:nth-child(3) {
  animation-delay: 0.06s;
}

.report-card:nth-child(4) {
  animation-delay: 0.09s;
}

.report-card h3 {
  font-family: var(--display);
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.report-card p {
  margin: 0 0 12px;
  color: var(--text-2);
  font-size: 0.9rem;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 16px;
}

.pill {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: rgba(125, 147, 171, 0.18);
  color: var(--text-1);
  border: 1px solid rgba(125, 147, 171, 0.26);
}

.pill.ok {
  background: rgba(62, 216, 171, 0.18);
  border-color: rgba(62, 216, 171, 0.38);
}

.pill.warn {
  background: rgba(245, 190, 102, 0.18);
  border-color: rgba(245, 190, 102, 0.36);
}

.pill.neutral {
  background: rgba(90, 178, 255, 0.18);
  border-color: rgba(90, 178, 255, 0.34);
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid rgba(125, 147, 171, 0.26);
  border-radius: 12px;
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: rgba(7, 13, 22, 0.55);
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(125, 147, 171, 0.18);
  text-align: left;
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.01);
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(9, 17, 28, 0.98);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}

.col-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  margin-left: 4px;
  border-radius: 50%;
  border: 1px solid rgba(125, 147, 171, 0.5);
  color: var(--text-2);
  font-size: 0.65rem;
  vertical-align: middle;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  border: 1px solid transparent;
}

.status-na {
  background: rgba(245, 190, 102, 0.18);
  color: #ffd48c;
  border-color: rgba(245, 190, 102, 0.36);
}

.status-pos {
  background: rgba(62, 216, 171, 0.2);
  color: #9ff1d4;
  border-color: rgba(62, 216, 171, 0.4);
}

.status-neg {
  background: rgba(125, 147, 171, 0.16);
  color: #d6e2f0;
  border-color: rgba(125, 147, 171, 0.3);
}

.status-ok {
  background: rgba(90, 178, 255, 0.18);
  color: #beddff;
  border-color: rgba(90, 178, 255, 0.36);
}

.status-warn {
  background: rgba(245, 190, 102, 0.2);
  color: #ffe1a7;
  border-color: rgba(245, 190, 102, 0.38);
}

.inline-link {
  color: #9fd0ff;
  text-decoration: underline;
}

.report-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0 12px;
}

.report-search-input {
  flex: 1 1 260px;
  max-width: 420px;
}

.btn-mini {
  padding: 6px 12px;
  font-size: 0.78rem;
}

.btn-mini.active {
  border-color: rgba(90, 178, 255, 0.7);
  background: rgba(90, 178, 255, 0.2);
}

.report-tools-meta {
  color: var(--text-3);
  font-size: 0.78rem;
}

.insights-box {
  border: 1px solid rgba(125, 147, 171, 0.24);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(10, 17, 28, 0.5);
  margin: 8px 0 14px;
}

.column-guide {
  margin: 8px 0 12px;
  border: 1px solid rgba(125, 147, 171, 0.24);
  border-radius: 12px;
  background: rgba(10, 17, 28, 0.45);
  padding: 8px 10px;
}

.column-guide summary {
  cursor: pointer;
  color: var(--text-2);
  font-size: 0.82rem;
}

.column-guide ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--text-2);
}

.column-guide li {
  margin: 4px 0;
}

.insights-title {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
}

.insight-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text-2);
}

.insight-list li {
  margin: 4px 0;
}

.empty-state {
  padding: 36px;
  border-radius: var(--radius);
  background: rgba(12, 21, 35, 0.7);
  border: 1px dashed rgba(125, 147, 171, 0.34);
  text-align: center;
}

.empty-state h3 {
  margin-top: 0;
  font-family: var(--display);
}

.empty-state p {
  color: var(--text-2);
}

.footer {
  padding: 22px 36px 34px;
  text-align: center;
  color: var(--text-3);
  position: relative;
  z-index: 1;
}

.report-list::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.report-list::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
  background: rgba(125, 147, 171, 0.35);
  border-radius: 999px;
}

.report-list::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track {
  background: rgba(125, 147, 171, 0.1);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1120px) {
  .layout {
    grid-template-columns: 320px minmax(0, 1fr);
    padding: 20px 24px 48px;
  }

  .topbar,
  .footer {
    padding-left: 24px;
    padding-right: 24px;
  }
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding-top: 16px;
    padding-bottom: 14px;
  }

  .layout {
    padding-left: 14px;
    padding-right: 14px;
  }

  .summary-bar {
    grid-template-columns: 1fr;
  }

  .selection-actions {
    flex-wrap: wrap;
  }
}

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