:root {
  color-scheme: dark;
  --bg: #101214;
  --surface: #171a1d;
  --surface-2: #1f2428;
  --surface-3: #262c31;
  --line: #343c43;
  --ink: #f4f7f8;
  --muted: #a9b5bd;
  --teal: #51d6b4;
  --blue: #73b7ff;
  --amber: #f0bc57;
  --rose: #f0778a;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(81, 214, 180, 0.12), transparent 28rem),
    linear-gradient(315deg, rgba(115, 183, 255, 0.08), transparent 24rem),
    var(--bg);
  color: var(--ink);
  font-family: Inter, Segoe UI, system-ui, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

h1 {
  font-size: 21px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

h3 {
  font-size: 15px;
}

p,
.muted {
  color: var(--muted);
}

.shell {
  width: min(1800px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 42px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 0 16px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
}

.mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  border: 1px solid rgba(81, 214, 180, 0.42);
  background: radial-gradient(circle at 68% 18%, rgba(240, 188, 87, 0.32), transparent 30%), var(--surface-2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.mark svg {
  width: 42px;
  height: 42px;
}

.logo-head,
.logo-neck,
.logo-wing,
.logo-snout {
  fill: #51d6b4;
}

.logo-neck,
.logo-wing {
  opacity: 0.62;
}

.logo-horn,
.logo-board {
  fill: #f0bc57;
}

.logo-glasses,
.logo-line,
.logo-math {
  fill: none;
  stroke: #06231c;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.logo-math {
  stroke-width: 1.8;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}

.tab {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}

.tab:hover,
.tab.active {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
}

.view {
  padding-top: 18px;
}

.intro-band,
.summary-band,
.averages-section,
.difficulty-section,
.section-block,
.toolbar {
  border-bottom: 1px solid var(--line);
}

.intro-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0 22px;
}

.intro-band p {
  max-width: 840px;
  margin-top: 6px;
}

.freshness {
  display: grid;
  gap: 5px;
  min-width: 210px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.freshness span,
label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.freshness strong {
  font-size: 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 18px 0;
}

.metric-card {
  min-height: 104px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  line-height: 1;
}

.metric-card strong.metric-value-small {
  font-size: 18px;
  line-height: 1.18;
}

.metric-card p {
  margin-top: 8px;
}

.section-block {
  padding: 18px 0;
}

.summary-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0;
}

.summary-band p {
  margin-top: 5px;
}

.controls {
  display: flex;
  align-items: end;
  gap: 12px;
}

.radio-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.radio-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.radio-pill input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--teal);
}

.radio-pill:has(input:checked) {
  border-color: rgba(81, 214, 180, 0.7);
  background: rgba(81, 214, 180, 0.1);
  color: var(--ink);
}

.radio-pill span {
  color: inherit;
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 0 0 16px;
}

label {
  display: grid;
  gap: 7px;
}

select,
input[type="search"] {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
}

select {
  min-width: 280px;
  padding-right: 36px;
}

input[type="search"] {
  width: min(520px, calc(100vw - 32px));
}

.toolbar-stat {
  color: var(--muted);
  font-weight: 700;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(460px, 1.05fr);
  gap: 20px;
}

.detail-panel {
  position: sticky;
  top: 0;
  align-self: start;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

td.value,
th.value {
  text-align: right;
}

tr.selectable {
  cursor: pointer;
}

tr.selectable:hover,
tr.selected {
  background: rgba(81, 214, 180, 0.08);
}

.pill-row,
.mini-grid,
.drop-list,
.level-grid {
  display: grid;
  gap: 10px;
}

.mini-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
}

.mini-stat {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.mini-stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.mini-stat strong {
  display: block;
  margin-top: 7px;
  font-size: 20px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
}

.item-id {
  color: var(--muted);
  font-size: 12px;
}

.average-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding-bottom: 20px;
}

.average-card,
.difficulty-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.average-card {
  padding: 14px;
}

.average-head,
.difficulty-head,
.pool-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.average-head {
  margin-bottom: 12px;
}

.tier-averages {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.tier-averages div,
.stat-strip div {
  min-width: 0;
}

.tier-averages span,
.stat-strip span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.tier-averages strong,
.stat-strip strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-size: 15px;
}

.difficulty-grid {
  display: grid;
  gap: 16px;
  padding-bottom: 24px;
}

.ranking-grid {
  display: grid;
  gap: 16px;
  padding-bottom: 24px;
}

.ranking-card {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.ranking-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.ranking-difficulty-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 8px;
  padding: 8px;
}

.ranking-difficulty {
  min-width: 0;
}

.ranking-difficulty-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px 8px;
}

.ranking-table {
  width: 100%;
  table-layout: fixed;
}

.ranking-table .rank-col {
  width: 28px;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ranking-table .col-raid {
  width: 29%;
  white-space: nowrap;
}

.ranking-table .col-components {
  width: 46%;
}

.ranking-table .col-entries,
.ranking-table .col-value {
  width: 38px;
  white-space: nowrap;
}

.ranking-table th,
.ranking-table td {
  padding: 5px 6px;
}

.strong-value {
  color: var(--teal);
  font-weight: 850;
}

.mini-parts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
  overflow: visible;
  row-gap: 3px;
}

.mini-part {
  display: inline-flex;
  flex: 0 0 auto;
  min-height: 20px;
  align-items: center;
  padding: 0 5px;
  border-radius: 5px;
  background: rgba(81, 214, 180, 0.1);
  color: var(--teal);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.mini-part[data-label="ad"] {
  background: rgba(240, 188, 87, 0.12);
  color: var(--amber);
}

.mini-part[data-label="max le"] {
  padding-inline: 6px;
  background: rgba(115, 183, 255, 0.12);
  color: var(--blue);
}

.text-link {
  display: block;
  width: 100%;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 750;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-link:hover {
  color: var(--teal);
}

.toggle-control {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 9px;
}

.toggle-control input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--teal);
}

.difficulty-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.keen-eye-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.keen-eye-rate {
  display: grid;
  min-width: 112px;
  justify-items: end;
  gap: 2px;
}

.keen-eye-rate span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.keen-eye-rate strong {
  color: var(--amber);
  font-size: 24px;
  line-height: 1;
  font-weight: 900;
}

.stat-strip {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--muted);
  text-align: right;
}

.pool-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.special-pool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

.single-pool-grid {
  display: grid;
  grid-template-columns: 1fr;
  border-top: 1px solid var(--line);
}

.ap-breakdown-table {
  display: grid;
  padding: 8px 12px 14px;
}

.ap-table-head,
.ap-summary-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px minmax(100px, 140px) 76px;
  align-items: center;
  gap: 10px;
}

.ap-table-head {
  padding: 7px 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.ap-detail {
  min-width: 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: rgba(255, 255, 255, 0.015);
}

.ap-detail:first-of-type {
  border-radius: 8px 8px 0 0;
}

.ap-detail:last-child {
  border-bottom: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
}

.ap-summary-row {
  min-height: 40px;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 750;
}

.ap-summary-row::marker {
  color: var(--muted);
}

.ap-summary-row:hover {
  background: rgba(81, 214, 180, 0.08);
}

.ap-summary-row span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ap-bar-cell {
  min-width: 0;
}

.ap-breakdown-table .bar,
.ap-drop-table .bar {
  width: 100%;
}

.ap-detail-body {
  padding: 0 12px 12px 30px;
}

.ap-nested-table {
  display: grid;
}

.ap-nested-table .ap-detail {
  background: rgba(0, 0, 0, 0.08);
}

.ap-color-row .ap-summary-row {
  font-weight: 700;
}

.ap-drop-table {
  table-layout: fixed;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.ap-drop-table th,
.ap-drop-table td {
  padding: 6px 8px;
}

.ap-drop-table td:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ap-drop-table th.value,
.ap-drop-table td.value {
  width: 72px;
}

.ap-drop-table .bar-cell {
  width: 140px;
}

.pool {
  min-width: 0;
  border-right: 1px solid var(--line);
}

.pool:last-child,
.single-pool-grid .pool,
.special-pool:nth-child(2n),
.special-pool:last-child {
  border-right: 0;
}

.pool-title {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.015);
}

.pool[data-tier="rare"] .bar span {
  background: var(--blue);
}

.pool[data-tier="mythic"] .bar span {
  background: var(--rose);
}

.pool[data-tier="special"] .bar span,
.pool[data-tier="keen-eye"] .bar span,
.pool[data-tier="ap"] .bar span {
  background: var(--amber);
}

.bar-cell {
  min-width: 110px;
}

.bar {
  width: 130px;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
}

.bar span {
  display: block;
  width: var(--w);
  max-width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue));
}

.empty {
  padding: 18px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.tone-teal { color: var(--teal); }
.tone-blue { color: var(--blue); }
.tone-amber { color: var(--amber); }
.tone-rose { color: var(--rose); }

@media (max-width: 1100px) {
  .topbar,
  .intro-band,
  .summary-band,
  .controls,
  .radio-strip,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs {
    margin-left: 0;
  }

  .radio-strip {
    justify-content: flex-start;
  }

  .brand,
  .freshness {
    min-width: 0;
  }

  .metric-grid,
  .mini-grid,
  .average-grid,
  .pool-grid,
  .special-pool-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split-layout {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }

  select {
    min-width: 0;
    width: 100%;
  }

  .keen-eye-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .keen-eye-rate {
    justify-items: start;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100vw - 20px, 1800px);
  }

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

  .metric-grid,
  .mini-grid,
  .average-grid,
  .pool-grid,
  .special-pool-grid,
  .ranking-difficulty-grid,
  .tier-averages {
    grid-template-columns: 1fr;
  }

  .tab {
    width: 100%;
  }
}
