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

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: #ffffff;
  color: #1a1a1a;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

.header {
  padding: 20px 28px;
  border-bottom: 1px solid #e5e5e5;
  display: flex;
  align-items: center;
  gap: 36px;
}

.header .logo {
  font-weight: 600;
  font-size: 16px;
  color: #1a1a1a;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header .logo img {
  height: 40px;
  display: block;
}

.header nav {
  display: flex;
  gap: 24px;
}

.header nav a {
  font-size: 14px;
  color: #71717a;
  transition: color 0.15s;
}

.header nav a:hover {
  color: #1a1a1a;
}

.top-right-btn {
  margin-left: auto;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
}

/* Page layout */
.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 60px 24px;
  flex: 1;
  width: 100%;
}

.page-header {
  margin-bottom: 24px;
}

h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: #1a1a1a;
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 14px;
  color: #71717a;
}

/* Filter bar */
.filter-bar {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e5e5e5;
}

.filter-section {
  margin-bottom: 14px;
}

.filter-section:last-of-type {
  margin-bottom: 0;
}

.filter-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.filter-label-optimal {
  color: #15803d;
}

.filter-label-found {
  color: #71717a;
}

.filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Single row, horizontal scroll, load more as you scroll */
.filter-chips-row {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: 4px;
}

.filter-chips-row .chip,
.filter-chips-row .chips-load-more {
  flex-shrink: 0;
}

.chips-load-more {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  font-size: 13px;
  color: #a1a1aa;
  pointer-events: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  text-decoration: none;
}

/* Known optimal - not selectable */
.chip-optimal {
  border: 1px solid #22c55e;
  background: #f0fdf4;
  color: #166534;
}

.chip-optimal:hover {
  background: #dcfce7;
  border-color: #16a34a;
}

.chip-optimal.chip-no-select {
  cursor: default;
  pointer-events: none;
}

.chip-optimal.chip-no-select:hover {
  background: #f0fdf4;
  border-color: #22c55e;
}

.chip-optimal .chip-count {
  color: #15803d;
}

.chip-optimal.active {
  background: #15803d;
  color: #ffffff;
  border-color: #15803d;
}

.chip-optimal.active .chip-count {
  color: #bbf7d0;
}

/* Best found - not proved */
.chip-found {
  border: 1px solid #e5e5e5;
  background: #fafafa;
  color: #1a1a1a;
}

.chip-found:hover {
  background: #f0f0f0;
  border-color: #d4d4d4;
}

.chip-found .chip-count {
  color: #71717a;
}

.chip-found.active {
  background: #1a1a1a;
  color: #ffffff;
  border-color: #1a1a1a;
}

.chip-found.active .chip-count {
  color: #a1a1aa;
}

.chip-count {
  font-size: 11px;
}

.no-data {
  font-size: 13px;
  color: #a1a1aa;
}

.filter-bar .no-data {
  margin-top: 4px;
}

/* Results wrapper: fade in when a square count is selected */
.results-wrapper {
  animation: resultsFadeIn 0.4s ease-out;
}

@keyframes resultsFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Staggered fade-in for table rows */
.results-table tbody tr {
  opacity: 0;
  animation: rowFadeIn 0.35s ease-out forwards;
}

.results-table tbody tr:nth-child(1)  { animation-delay: 0.05s; }
.results-table tbody tr:nth-child(2)  { animation-delay: 0.1s; }
.results-table tbody tr:nth-child(3)  { animation-delay: 0.15s; }
.results-table tbody tr:nth-child(4)  { animation-delay: 0.2s; }
.results-table tbody tr:nth-child(5)  { animation-delay: 0.25s; }
.results-table tbody tr:nth-child(6)  { animation-delay: 0.3s; }
.results-table tbody tr:nth-child(7)  { animation-delay: 0.35s; }
.results-table tbody tr:nth-child(8)  { animation-delay: 0.4s; }
.results-table tbody tr:nth-child(9)  { animation-delay: 0.45s; }
.results-table tbody tr:nth-child(10) { animation-delay: 0.5s; }
.results-table tbody tr:nth-child(11) { animation-delay: 0.55s; }
.results-table tbody tr:nth-child(12) { animation-delay: 0.6s; }
.results-table tbody tr:nth-child(13) { animation-delay: 0.65s; }
.results-table tbody tr:nth-child(14) { animation-delay: 0.7s; }
.results-table tbody tr:nth-child(15) { animation-delay: 0.75s; }
.results-table tbody tr:nth-child(16) { animation-delay: 0.8s; }
.results-table tbody tr:nth-child(17) { animation-delay: 0.85s; }
.results-table tbody tr:nth-child(18) { animation-delay: 0.9s; }
.results-table tbody tr:nth-child(19) { animation-delay: 0.95s; }
.results-table tbody tr:nth-child(20) { animation-delay: 1s; }
.results-table tbody tr:nth-child(n+21) { animation-delay: 1.05s; }

@keyframes rowFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Results header */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.results-label {
  font-size: 13px;
  color: #71717a;
}

/* Hide-duplicates toggle */
.dup-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #52525b;
  cursor: pointer;
  user-select: none;
}

.dup-toggle input[type="checkbox"] {
  accent-color: #1a1a1a;
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* Medal badges for top 3 valid submissions */
.medal {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}

.medal-gold {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
}

.medal-silver {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #94a3b8;
}

.medal-bronze {
  background: #fef2e8;
  color: #7c3a12;
  border: 1px solid #c2804e;
}

/* Duplicate row + asterisk */
.row-duplicate {
  background: #fafafa;
}

.row-duplicate:hover {
  background: #f5f5f5;
}

.dup-asterisk {
  color: #a1a1aa;
  font-weight: 600;
  margin-left: 3px;
  cursor: default;
}

.table-footnote {
  font-size: 12px;
  color: #a1a1aa;
  margin-top: 10px;
  padding-left: 2px;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.results-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.results-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: #71717a;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid #e5e5e5;
  background: #ffffff;
  white-space: nowrap;
}

.results-table td {
  padding: 7px 12px;
  border-bottom: 1px solid #f0f0f0;
  color: #1a1a1a;
  white-space: nowrap;
}

.submission-row {
  cursor: pointer;
  transition: background 0.1s;
}

.submission-row:hover {
  background: #fafafa;
}

.submission-row.active {
  background: #f5f5f5;
}

/* Detail row: slide down when entry is selected (animate inner div; td ignores max-height) */
.detail-row td {
  padding: 0 !important;
  border-bottom: 1px solid #e5e5e5;
  vertical-align: top;
}

.detail-row-inner {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease-out;
  background: #fafafa;
}

.detail-row.open .detail-row-inner {
  max-height: 480px;
}

.detail-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  background: #fafafa;
}

.solution-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.solution-action-btn,
.solution-download-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: #1a1a1a;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
  display: inline-block;
}

.solution-action-btn:hover,
.solution-download-btn:hover {
  background: #f5f5f5;
  border-color: #d4d4d4;
}

.solution-action-view {
  color: #0d6efd;
  border-color: #0d6efd;
}

.solution-action-view:hover {
  background: #e8f0fe;
  border-color: #0a58ca;
}

.solution-svg-container {
  display: block;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  background: #ffffff;
  line-height: 0;
}

.solution-svg {
  display: block;
  border-radius: 8px;
  max-width: 100%;
  height: auto;
}

.mono {
  font-family: 'DM Mono', 'JetBrains Mono', monospace;
  font-size: 12px;
}

.col-rank {
  width: 50px;
  color: #71717a;
  text-align: center;
}

.col-user {
  min-width: 100px;
}

.col-obj {
  min-width: 180px;
}

.col-obj .unit {
  font-style: italic;
  font-size: 11px;
  color: #a1a1aa;
  margin-left: 2px;
}

.results-table th i {
  font-style: italic;
}

.col-status {
  width: 100px;
}

.col-date {
  width: 140px;
  color: #71717a;
  font-size: 12px;
}

/* Status dot */
.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.status-dot.status-pending { background: #f59e0b; }
.status-dot.status-valid   { background: #10b981; }
.status-dot.status-invalid { background: #ef4444; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e5e5e5;
}

.page-btn {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #1a1a1a;
  background: #f5f5f5;
  border: 1px solid #e5e5e5;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
}

.page-btn:hover {
  background: #ececec;
  border-color: #d4d4d4;
}

.page-btn.disabled {
  color: #c4c4c4;
  background: #fafafa;
  border-color: #f0f0f0;
  pointer-events: none;
}

.page-info {
  font-size: 13px;
  color: #71717a;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: #71717a;
  font-size: 14px;
}

/* Responsive */
@media (max-width: 640px) {
  .page {
    padding: 40px 12px;
  }

  .results-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .col-date {
    display: none;
  }
}
