.stats-directory-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.stats-directory-head > div:first-child > span {
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 800;
}

.stats-directory-head h1 {
  margin: 5px 0 6px;
  font-size: 26px;
  letter-spacing: -.04em;
}

.stats-directory-head p {
  margin: 0;
  color: var(--sub);
  font-size: 12.5px;
}

.stats-directory-meta {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.stats-directory-meta span {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--dim);
  background: var(--card);
  font-size: 10.5px;
  white-space: nowrap;
}

.stats-directory-meta strong {
  margin-right: 2px;
  color: var(--text);
  font-size: 12px;
}

.stats-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 168px auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
}

.stats-search input,
.stats-toolbar select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--card);
  font: inherit;
  font-size: 12px;
}

.stats-search input {
  padding: 0 12px;
}

.stats-toolbar select {
  padding: 0 30px 0 10px;
}

.stats-search input:focus,
.stats-toolbar select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
  outline: 0;
}

.stats-result-count {
  min-width: 70px;
  color: var(--dim);
  font-size: 11px;
  text-align: right;
}

.stats-filter-scroll {
  margin-bottom: 7px;
  overflow-x: auto;
  scrollbar-width: none;
}

.stats-filter-scroll::-webkit-scrollbar {
  display: none;
}

.stats-filters {
  display: flex;
  gap: 6px;
  min-width: max-content;
}

.stats-filters button {
  min-height: 31px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--sub);
  background: var(--card);
  font-size: 11px;
  white-space: nowrap;
}

.stats-filters button:hover {
  color: var(--text);
  border-color: var(--dim);
}

.stats-filters button.is-active {
  color: var(--bg);
  border-color: var(--text);
  background: var(--text);
  font-weight: 700;
}

.stats-table-guide {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-height: 17px;
  margin: 0 2px 6px;
  color: var(--dim);
  font-size: 9.5px;
}

.stats-table-guide b {
  font-weight: 750;
}

.stats-table {
  overflow: clip;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  box-shadow: 0 5px 16px rgb(0 0 0 / 2%);
}

.stats-row-grid {
  display: grid;
  grid-template-columns:
    minmax(180px, 1.55fr)
    96px
    68px
    repeat(3, minmax(92px, .78fr))
    minmax(144px, 1.1fr)
    14px;
  align-items: center;
  gap: 10px;
}

.stats-row-grid > * {
  min-width: 0;
}

.stats-table-head {
  position: sticky;
  z-index: 2;
  top: 0;
  min-height: 38px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  color: var(--dim);
  background: var(--head);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.2;
}

.stats-table-head > span,
.stats-table-head > button {
  min-width: 0;
}

.stats-table-head .is-number,
.stats-table-head > button {
  text-align: right;
}

.stats-table-head > button {
  padding: 0;
  border: 0;
  color: var(--dim);
  background: transparent;
  font: inherit;
}

.stats-table-head > button::after {
  margin-left: 3px;
  color: var(--line);
  content: "↕";
}

.stats-table-head > button:hover,
.stats-table-head > button.is-active {
  color: var(--text);
}

.stats-table-head > button.is-active::after {
  color: var(--accent);
  content: "↓";
}

.stats-stock-row {
  position: relative;
  isolation: isolate;
  min-width: 0;
  min-height: 48px;
  padding: 5px 14px;
  border-bottom: 1px solid var(--line2);
  color: var(--text);
  background: var(--card);
  transition: background-color .12s ease, box-shadow .12s ease;
}

.stats-stock-row:last-child {
  border-bottom: 0;
}

.stats-stock-row:hover,
.stats-stock-row:focus-visible {
  color: var(--text);
  background: var(--head);
  outline: 0;
}

.stats-stock-row:focus-visible {
  box-shadow: inset 3px 0 0 var(--accent);
}

.stats-stock-row:focus-within {
  box-shadow: inset 3px 0 0 var(--accent);
}

.stats-stock-row[hidden] {
  display: none;
}

.stats-row-stock {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.stats-row-stock-text {
  min-width: 0;
}

.stats-row-stock-text > strong {
  display: block;
  overflow: hidden;
  font-size: 12.5px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-row-stock-text > span {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  color: var(--dim);
  font-size: 9.5px;
  line-height: 1.2;
}

.stats-row-stock em {
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--accent);
  background: var(--focus);
  font-size: 8px;
  font-style: normal;
  font-weight: 800;
}

.watchlist-toggle {
  position: relative;
  z-index: 3;
  display: inline-grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 5px;
  color: var(--dim);
  background: transparent;
  font-size: 16px;
  line-height: 1;
}

.watchlist-toggle:hover {
  color: var(--text);
  background: var(--head);
}

.watchlist-toggle[aria-pressed="true"] {
  color: #e3a008;
}

.watchlist-toggle:focus-visible {
  box-shadow: 0 0 0 3px var(--focus);
  outline: 0;
}

.stats-row-price,
.stats-row-change,
.stats-row-flow {
  display: block;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stats-row-price {
  font-size: 12.5px;
  font-weight: 750;
}

.stats-row-change,
.stats-row-flow {
  font-size: 10.5px;
}

.stats-row-flow strong,
.stats-row-change strong {
  font-weight: 600;
}

.stats-stock-row .up,
.stats-table-guide .up {
  color: var(--up);
  color: color-mix(in srgb, var(--up) 78%, var(--sub));
}

.stats-stock-row .down,
.stats-table-guide .down {
  color: var(--down);
  color: color-mix(in srgb, var(--down) 78%, var(--sub));
}

.stats-row-opinion {
  overflow: hidden;
  min-width: 0;
}

.stats-opinion-pending,
.stats-opinion-empty {
  display: block;
  color: var(--dim);
  font-size: 9.5px;
  text-align: center;
}

.stats-opinion-bar {
  display: grid;
  grid-template-columns: var(--card-up) var(--card-down);
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line2);
}

.stats-opinion-bar i:first-child {
  background: var(--up);
  opacity: .72;
}

.stats-opinion-bar i:last-child {
  background: var(--down);
  opacity: .72;
}

.stats-row-opinion > span:not(.stats-opinion-pending):not(.stats-opinion-empty) {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  margin-top: 5px;
  font-size: 8.5px;
}

.stats-row-opinion b {
  font-weight: 500;
}

.stats-row-opinion em {
  margin-left: auto;
  color: var(--dim);
  font-style: normal;
}

.stats-row-arrow {
  color: var(--dim);
  font-size: 18px;
  text-align: right;
  transition: color .12s ease, transform .12s ease;
}

.stats-stock-row:hover .stats-row-arrow,
.stats-stock-row:focus-within .stats-row-arrow {
  color: var(--sub);
  transform: translateX(2px);
}

.stats-row-link {
  position: absolute;
  z-index: 1;
  inset: 0;
  border-radius: inherit;
}

.stats-row-link:focus-visible {
  outline: 0;
}

.stats-load-more {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--card);
}

.stats-load-more[hidden] {
  display: none;
}

.stats-load-more button {
  min-width: 106px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: var(--head);
  font-size: 10.5px;
  font-weight: 650;
}

.stats-load-more button:hover {
  border-color: var(--dim);
}

.stats-load-more span {
  color: var(--dim);
  font-size: 10.5px;
}

.stats-directory-empty {
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 5px;
  min-height: 220px;
  padding: 60px 20px;
  color: var(--dim);
  text-align: center;
}

.stats-directory-empty[hidden] {
  display: none;
}

.stats-directory-empty strong {
  color: var(--text);
  font-size: 13px;
}

.stats-directory-empty span {
  font-size: 11px;
}

@media (min-width: 721px) and (max-width: 1000px) {
  .stats-row-grid {
    grid-template-columns: minmax(160px, 1fr) 92px 68px minmax(82px, .75fr) minmax(82px, .75fr) 14px;
    gap: 9px;
  }

  .stats-table-head > :nth-child(4),
  .stats-table-head > :nth-child(7),
  .stats-row-individual,
  .stats-row-opinion {
    display: none;
  }
}

@media (max-width: 720px) {
  .stats-directory-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 15px;
  }

  .stats-directory-head h1 {
    font-size: 23px;
  }

  .stats-directory-head p {
    max-width: 340px;
    font-size: 11.5px;
    line-height: 1.6;
  }

  .stats-directory-meta {
    width: 100%;
  }

  .stats-directory-meta span {
    flex: 1;
    padding: 6px;
    text-align: center;
  }

  .stats-toolbar {
    grid-template-columns: minmax(0, 1fr) 126px;
  }

  .stats-result-count {
    grid-column: 1 / -1;
    grid-row: 2;
    min-height: 14px;
    text-align: left;
  }

  .stats-table-guide {
    justify-content: space-between;
    gap: 8px;
    font-size: 9px;
  }

  .stats-table-head {
    display: none;
  }

  .stats-table {
    border-radius: 8px;
  }

  .stats-stock-row {
    grid-template-areas:
      "stock price change arrow"
      "stock foreign institution arrow";
    grid-template-columns: minmax(100px, 1fr) 82px 64px 12px;
    gap: 4px 9px;
    min-height: 60px;
    padding: 7px 12px;
  }

  .stats-row-stock {
    grid-area: stock;
  }

  .stats-row-price {
    grid-area: price;
  }

  .stats-row-change {
    grid-area: change;
  }

  .stats-row-foreign {
    grid-area: foreign;
  }

  .stats-row-institution {
    grid-area: institution;
  }

  .stats-row-arrow {
    grid-area: arrow;
    align-self: center;
  }

  .stats-row-individual,
  .stats-row-opinion {
    display: none;
  }

  .stats-row-foreign::before,
  .stats-row-institution::before {
    display: block;
    margin-bottom: 1px;
    color: var(--dim);
    font-size: 8px;
  }

  .stats-row-foreign::before {
    content: "외국인";
  }

  .stats-row-institution::before {
    content: "기관";
  }

  .stats-row-price {
    font-size: 11.5px;
  }

  .stats-row-change,
  .stats-row-flow {
    font-size: 9.5px;
  }
}
