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

:root {
  --bg: #0f1519;
  --bg-accent: #182127;
  --surface: rgba(19, 28, 34, 0.86);
  --surface-strong: #1c262d;
  --surface-soft: #223038;
  --border: rgba(222, 232, 237, 0.1);
  --border-strong: rgba(222, 232, 237, 0.18);
  --text: #f4efe6;
  --muted: #a7b3b8;
  --accent: #176b5d;
  --accent-2: #c46d2d;
  --green: #1f8f67;
  --red: #bf4a3b;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(196, 109, 45, 0.2), transparent 28%),
    radial-gradient(circle at top right, rgba(23, 107, 93, 0.16), transparent 24%),
    linear-gradient(180deg, #091015 0%, var(--bg) 46%, var(--bg-accent) 100%);
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.4), transparent 75%);
}

main {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
}

.filters,
.qr-banner,
.monitor-panel,
.chart-card,
.table-section,
.modal-box,
.momentum-card {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.hero-copy {
  border-radius: var(--radius-lg);
  padding: 32px;
}

.card-kicker,
.filter-group label,
thead th {
  font-family: "Segoe UI", Arial, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.card-kicker {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

main {
  padding: 8px 0 40px;
}

.qr-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-radius: 24px;
  padding: 22px 24px;
  margin-bottom: 20px;
}

.qr-banner h1 {
  margin-top: 8px;
  font-size: 34px;
  line-height: 1.05;
  font-weight: 600;
}

.qr-banner p {
  margin-top: 10px;
  color: var(--muted);
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.55;
}

.qr-banner-image {
  width: clamp(160px, 22vw, 240px);
  aspect-ratio: 1;
  display: block;
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 14px;
  align-items: center;
  border-radius: 24px;
  padding: 18px;
  margin-bottom: 20px;
}

.filter-group {
  display: block;
}

.filter-group select,
.section-header select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 11px 14px;
  font-size: 13px;
  outline: none;
  font-family: "Segoe UI", Arial, sans-serif;
}

.filter-group select:focus,
.filter-group input:focus,
.section-header select:focus {
  border-color: rgba(23, 107, 93, 0.42);
}

.filter-group.search input {
  min-width: 0;
}

#btnApply {
  border: none;
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  padding: 12px 18px;
  cursor: pointer;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 13px;
  font-weight: 700;
}

.charts-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
  margin-bottom: 20px;
}

.chart-card {
  border-radius: 24px;
  padding: 22px 24px 18px;
}

.chart-card.wide {
  grid-column: 1 / -1;
}

.chart-card h2,
.section-header h2,
.table-header h2,
.modal-box h3 {
  font-size: 26px;
  line-height: 1.08;
  font-weight: 600;
}

.chart-card h2 {
  margin-top: 8px;
  margin-bottom: 18px;
}

.section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 34px 0 14px;
}

.section-sub,
#tableCount,
#liveCount,
#monitorUpdated,
.monitor-label,
.monitor-meta,
.artist,
.release,
.modal-box p,
.empty-state {
  color: var(--muted);
  font-family: "Segoe UI", Arial, sans-serif;
}

.monitor-panel {
  border-radius: 24px;
  padding: 20px;
  margin-bottom: 20px;
}

.monitor-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.monitor-heading h2 {
  margin-top: 8px;
  font-size: 26px;
  line-height: 1.08;
  font-weight: 600;
}

.monitor-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.monitor-item {
  min-height: 132px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.monitor-label {
  font-size: 11px;
}

.monitor-status {
  margin-top: 10px;
  min-height: 24px;
  overflow-wrap: anywhere;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 600;
}

.monitor-status.good {
  color: var(--green);
}

.monitor-status.warn {
  color: var(--accent-2);
}

.monitor-bar {
  height: 8px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.monitor-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 8px;
  background: var(--green);
  transition: width 0.25s ease;
}

.monitor-meta {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.45;
}

.section-sub {
  margin-top: 8px;
  max-width: 58ch;
  line-height: 1.55;
}

.momentum-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.momentum-card {
  border-radius: 22px;
  padding: 18px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.momentum-card:hover,
tbody tr:hover {
  transform: translateY(-2px);
}

.momentum-card:hover {
  border-color: rgba(23, 107, 93, 0.28);
}

.momentum-card .m-rank,
.momentum-card .m-label {
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 11px;
  color: var(--muted);
}

.momentum-card .m-title {
  margin-top: 10px;
  font-size: 20px;
  line-height: 1.12;
  font-weight: 600;
}

.momentum-card .m-artist {
  margin-top: 4px;
  font-size: 13px;
}

.momentum-card .m-growth {
  margin-top: 18px;
  font-size: 34px;
  line-height: 1;
  color: var(--green);
  font-weight: 600;
}

.momentum-card .m-growth.falling {
  color: var(--red);
}

.momentum-card .m-peak {
  margin-top: 12px;
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(196, 109, 45, 0.12);
  color: var(--accent-2);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 11px;
}

.momentum-card .m-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(31, 143, 103, 0.2);
  background: rgba(31, 143, 103, 0.1);
  color: var(--green);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.momentum-card .m-badge.falling {
  border-color: rgba(191, 74, 59, 0.2);
  background: rgba(191, 74, 59, 0.1);
  color: var(--red);
}

.table-section {
  border-radius: 24px;
  overflow: hidden;
  margin-bottom: 20px;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

#tableCount,
#liveCount {
  font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
}

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

thead th {
  padding: 12px 22px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.16s ease, transform 0.16s ease;
  cursor: pointer;
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.52);
}

tbody td {
  padding: 15px 22px;
  vertical-align: middle;
}

.title {
  max-width: 240px;
  font-size: 16px;
  font-weight: 600;
}

.title a {
  color: var(--text);
  text-decoration: none;
}

.title a:hover {
  color: var(--accent);
}

.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 11px;
  font-weight: 700;
}

.usage {
  white-space: nowrap;
}

.release {
  white-space: nowrap;
  font-size: 12px;
}

.growth-up,
.growth-down,
.diff-up,
.diff-down,
.diff-same {
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 12px;
  font-weight: 700;
}

.growth-up,
.diff-up {
  color: var(--green);
}

.growth-down,
.diff-down {
  color: var(--red);
}

.diff-same {
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(31, 26, 20, 0.45);
  z-index: 100;
}

.modal.hidden {
  display: none;
}

.modal-box {
  position: relative;
  width: min(720px, 100%);
  border-radius: 28px;
  padding: 28px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
}

.modal-box p {
  margin-top: 6px;
  margin-bottom: 18px;
  font-size: 13px;
}

.peak-info {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(196, 109, 45, 0.08);
  border: 1px solid rgba(196, 109, 45, 0.18);
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.65;
}

.empty-state {
  padding: 44px 24px;
  text-align: center;
  font-size: 14px;
}

.hidden {
  display: none;
}

.sparkline {
  display: block;
}

canvas {
  width: 100% !important;
}

@media (max-width: 1024px) {
  .hero,
  .charts-row {
    grid-template-columns: 1fr;
  }

  .monitor-grid {
    grid-template-columns: 1fr;
  }

  .hero-copy h1 {
    max-width: none;
  }

  .live-badge {
    justify-self: start;
  }

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

@media (max-width: 720px) {
  .hero,
  main {
    width: min(100% - 20px, 1240px);
  }

  .hero {
    padding-top: 18px;
  }

  .hero-copy,
  .hero-panel,
  .chart-card,
  .table-section,
  .filters,
  .qr-banner,
  .monitor-panel,
  .momentum-card,
  .modal-box {
    border-radius: 22px;
  }

  .hero-copy,
  .hero-panel,
  .chart-card,
  .filters,
  .qr-banner,
  .modal-box {
    padding: 20px;
  }

  .qr-banner {
    align-items: flex-start;
    flex-direction: column;
  }

  .qr-banner-image {
    width: min(100%, 240px);
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .section-header,
  .table-header {
    flex-direction: column;
    align-items: flex-start;
  }

  thead th,
  tbody td {
    padding-left: 14px;
    padding-right: 14px;
  }

  .title {
    max-width: 160px;
  }
}
