:root {
  --bg: #e8eef3;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --accent-compound: #334155;
  --accent-win: #16a34a;
  --win-value: #16a34a;
  --compound-value: #1e3a5f;
  --shadow: 0 4px 18px rgba(15, 23, 42, 0.08);
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100%;
}

.wrap {
  width: min(1100px, calc(100% - 2rem));
  margin-inline: auto;
}

.page-head {
  padding: 2rem 0 1rem;
}
.page-head h1 {
  margin: 0 0 0.35rem;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-head .sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}
.page-head .meta {
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.1rem;
  padding-bottom: 2.5rem;
}

.market-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.market-card:hover {
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.12);
  transform: translateY(-1px);
}
.market-card:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}
.market-card.is-empty {
  opacity: 0.55;
}

.market-card__head {
  padding: 1rem 1.15rem 0.65rem;
  border-bottom: 1px solid #eef2f7;
}
.market-card__head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}
.market-card__head .site {
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}
.market-card__head .data-date {
  margin: 0.45rem 0 0;
  font-size: 0.8rem;
  color: #334155;
}
.market-card__head .data-date strong {
  font-weight: 700;
  color: #0f172a;
}
.market-card__head .data-date--empty {
  color: var(--muted);
  font-weight: 400;
}

.metric {
  padding: 0.95rem 1.15rem;
  border-left: 4px solid transparent;
}
.metric + .metric {
  border-top: 1px solid #f1f5f9;
}
.metric--compound {
  border-left-color: var(--accent-compound);
}
.metric--win {
  border-left-color: var(--accent-win);
}

.metric__label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
}
.metric__label svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.85;
}
.metric__value {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.metric--compound .metric__value {
  color: var(--compound-value);
}
.metric--win .metric__value {
  color: var(--win-value);
}
.metric__foot {
  margin: 0.35rem 0 0;
  font-size: 0.7rem;
  color: var(--muted);
}

.err {
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 0.85rem 1rem;
}

.page-foot {
  padding: 0 0 2rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.skel {
  height: 180px;
  background: linear-gradient(90deg, #fff 0%, #f1f5f9 50%, #fff 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  border-radius: var(--radius);
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Modal */
body.modal-open { overflow: hidden; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal[hidden] { display: none !important; }
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}
.modal__dialog {
  position: relative;
  z-index: 1;
  width: min(1200px, 100%);
  max-height: min(92vh, 900px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #eef2f7;
}
.modal__head h2 {
  margin: 0;
  font-size: 1.25rem;
}
.modal__sub {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.modal__close {
  border: 0;
  background: #f1f5f9;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
}
.modal__close:hover { background: #e2e8f0; }

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 1.25rem 0;
  border-bottom: 1px solid #eef2f7;
  background: #fafbfc;
}
.tab {
  border: 0;
  background: transparent;
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab.is-active {
  color: var(--text);
  border-bottom-color: #2563eb;
}
.modal__body {
  padding: 0.75rem 1.25rem 1rem;
  overflow: auto;
  flex: 1;
}
.tab-panel { min-height: 200px; }
.table-wrap { width: 100%; overflow-x: auto; }
.modal__status {
  margin: 0.75rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

/* DataTables tweaks */
table.dataTable thead th {
  white-space: nowrap;
  font-size: 0.78rem;
}
table.dataTable tbody td {
  font-size: 0.8rem;
  white-space: nowrap;
}
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0.25rem 0.4rem;
}

