:root {
  --bg: #f3f5f8;
  --bg-deep: #e9edf2;
  --panel: rgba(255, 255, 255, 0.84);
  --panel-strong: rgba(255, 255, 255, 0.94);
  --panel-soft: rgba(15, 23, 42, 0.035);
  --text: #111827;
  --muted: #6b7280;
  --muted-strong: #475569;
  --line: rgba(15, 23, 42, 0.09);
  --line-strong: rgba(15, 23, 42, 0.15);
  --brand: #0f172a;
  --brand-soft: rgba(15, 23, 42, 0.06);
  --gold: #5f6f86;
  --positive: #16734c;
  --positive-soft: rgba(22, 115, 76, 0.1);
  --negative: #b54a36;
  --negative-soft: rgba(181, 74, 54, 0.1);
  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-pill: 999px;
  --shadow-soft: 0 10px 24px rgba(15, 23, 42, 0.045);
  --shadow-card: 0 8px 20px rgba(15, 23, 42, 0.04);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", sans-serif;
  background:
    linear-gradient(180deg, #fafbfd 0%, var(--bg) 42%, var(--bg-deep) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: linear-gradient(rgba(15, 23, 42, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.02) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.4), transparent 75%);
  opacity: 0.26;
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 28px 0 72px;
}

.hero,
.controls,
.table-shell,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
}

.hero {
  display: grid;
  gap: 18px;
  padding: 30px 32px 24px;
  background: var(--panel-strong);
}

.hero-copy {
  max-width: 780px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-family: "Iowan Old Style", "Songti SC", serif;
  font-size: clamp(30px, 4vw, 44px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.02;
}

.hero-text {
  margin: 10px 0 0;
  max-width: 52ch;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.stat-card {
  min-height: 92px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.46);
  box-shadow: none;
}

.stat-label {
  display: block;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.stat-card strong {
  display: block;
  font-size: clamp(23px, 3vw, 28px);
  font-weight: 600;
  line-height: 1.2;
}

#date-range {
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.5;
  white-space: nowrap;
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) repeat(3, minmax(150px, 1fr));
  gap: 14px;
  margin-top: 16px;
  padding: 14px;
  background: var(--panel-strong);
}

.field {
  display: grid;
  gap: 9px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field input,
.field select {
  width: 100%;
  min-height: 48px;
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  font-size: 14px;
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.field input::placeholder {
  color: rgba(111, 102, 93, 0.88);
}

.field input:hover,
.field select:hover {
  border-color: var(--line-strong);
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: rgba(95, 111, 134, 0.26);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 0 0 4px rgba(95, 111, 134, 0.08);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin: 16px 0 6px;
}

.filters,
.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.toolbar-actions {
  justify-content: flex-end;
}

.toolbar-actions .hidden {
  display: none;
}

.sync-status {
  color: var(--muted-strong);
  font-size: 13px;
}

.filter-chip,
.reset-button,
.page-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  font-size: 12px;
  letter-spacing: 0.02em;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.filter-chip.active,
.page-button.active {
  border-color: transparent;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
}

.static-chip {
  cursor: default;
}

.reset-button,
.page-button {
  cursor: pointer;
}

.reset-button:hover,
.page-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.reset-button:disabled,
.page-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.results-bar {
  margin: 8px 4px 16px;
}

.results-bar p {
  margin: 0;
  color: var(--muted-strong);
  font-size: 14px;
  line-height: 1.7;
}

.delist-section {
  margin-bottom: 24px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  margin: 0 2px 10px;
}

.section-heading h2 {
  margin: 0 0 6px;
  font-family: "Iowan Old Style", "Songti SC", serif;
  font-size: clamp(22px, 2.5vw, 28px);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.table-shell {
  overflow: auto;
  background: var(--panel-strong);
}

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

.contracts-table thead {
  background: rgba(15, 23, 42, 0.028);
}

.contracts-table th,
.contracts-table td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}

.contracts-table th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.contracts-table tbody tr {
  transition: background 0.18s ease;
}

.contracts-table tbody tr:hover {
  background: rgba(15, 23, 42, 0.022);
}

.contracts-table tbody tr:last-child td {
  border-bottom: none;
}

.listings-table th:nth-child(1),
.listings-table td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 3;
  min-width: 124px;
  background: var(--panel-strong);
}

.listings-table th:nth-child(2),
.listings-table td:nth-child(2) {
  position: sticky;
  left: 124px;
  z-index: 2;
  min-width: 168px;
  background: var(--panel-strong);
}

.listings-table thead th:nth-child(1),
.listings-table thead th:nth-child(2) {
  z-index: 4;
}

.listings-table tbody td:nth-child(1),
.listings-table tbody td:nth-child(2) {
  box-shadow: 1px 0 0 var(--line);
}

.market-badge,
.type-badge,
.status-badge,
.funding-rate {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 6px 11px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.market-badge {
  background: rgba(95, 111, 134, 0.1);
  color: #44546d;
}

.type-badge {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted-strong);
}

.status-badge {
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.045);
  color: var(--text);
}

.funding-rate {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted-strong);
}

.funding-rate.positive {
  color: var(--positive);
  border-color: rgba(22, 115, 76, 0.18);
  background: var(--positive-soft);
}

.funding-rate.negative {
  color: var(--negative);
  border-color: rgba(181, 74, 54, 0.18);
  background: var(--negative-soft);
}

.funding-rate.neutral {
  color: var(--muted-strong);
  background: rgba(15, 23, 42, 0.05);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.page-numbers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.page-ellipsis {
  display: inline-flex;
  align-items: center;
  padding: 0 4px;
  color: var(--muted);
}

.empty-state {
  margin-top: 18px;
  padding: 42px 26px;
  text-align: center;
  background: var(--panel-strong);
}

.empty-state h2 {
  margin: 0 0 8px;
  font-family: "Iowan Old Style", "Songti SC", serif;
  font-size: 28px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.hidden {
  display: none;
}

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

  .field.field-search {
    grid-column: 1 / -1;
  }
}

@media (max-width: 960px) {
  .page-shell {
    width: min(100vw - 24px, 1200px);
    padding-top: 20px;
  }

  .hero {
    padding: 24px 20px 20px;
  }

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

  .controls {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-actions {
    justify-content: stretch;
  }

  .reset-button {
    width: 100%;
  }

  #date-range {
    white-space: normal;
  }
}

@media (max-width: 760px) {
  body::before {
    opacity: 0.16;
  }

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

  .section-heading h2 {
    font-size: 25px;
  }

  .table-shell {
    border: 0;
    box-shadow: none;
    background: transparent;
    backdrop-filter: none;
  }

  .contracts-table,
  .contracts-table thead,
  .contracts-table tbody,
  .contracts-table tr,
  .contracts-table th,
  .contracts-table td {
    display: block;
  }

  .contracts-table thead {
    display: none;
  }

  .contracts-table tbody {
    display: grid;
    gap: 12px;
  }

  .contracts-table tr {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel-strong);
    box-shadow: var(--shadow-soft);
  }

  .listings-table th:nth-child(1),
  .listings-table td:nth-child(1),
  .listings-table th:nth-child(2),
  .listings-table td:nth-child(2) {
    position: static;
    left: auto;
    min-width: 0;
    box-shadow: none;
  }

  .contracts-table td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(63, 48, 34, 0.08);
  }

  .contracts-table td:last-child {
    border-bottom: none;
  }

  .contracts-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }

  .pagination {
    justify-content: stretch;
  }

  .page-button {
    flex: 1 1 auto;
  }
}
