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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f5f5f5;
  min-height: 100vh;
  color: #111;
}

.site-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e0e0e0;
}

.header-title h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.tagline {
  font-size: 13px;
  color: #666;
  margin-top: 4px;
}

/* Date Navigation */
.date-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-btn {
  width: 36px;
  height: 36px;
  border: 1px solid #e0e0e0;
  background: #fff;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: #333;
}

.nav-btn:hover:not(:disabled) {
  background: #f0f0f0;
  border-color: #ccc;
}

.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.date-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid #e0e0e0;
  background: #fff;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.date-picker:hover {
  background: #f0f0f0;
  border-color: #ccc;
}

.dropdown-arrow {
  font-size: 10px;
  color: #666;
}

/* Date Dropdown */
.date-dropdown {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  z-index: 1000;
  display: none;
  min-width: 200px;
  max-height: 400px;
  overflow: hidden;
}

.date-dropdown.open {
  display: block;
}

.dropdown-header {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #e8e8e8;
}

.date-list {
  max-height: 360px;
  overflow-y: auto;
}

/* Month Headers */
.month-header {
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  color: #333;
  background: #f8f8f8;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #e8e8e8;
  user-select: none;
  transition: background 0.1s ease;
}

.month-header:hover {
  background: #f0f0f0;
}

.month-toggle {
  font-size: 10px;
  color: #999;
  width: 12px;
}

.month-label {
  flex: 1;
}

.month-count {
  font-size: 11px;
  font-weight: 500;
  color: #999;
  background: #e8e8e8;
  padding: 2px 6px;
  border-radius: 10px;
}

/* Month Dates Container */
.month-dates {
  display: none;
}

.month-dates.expanded {
  display: block;
}

/* Day Rows */
.day-row {
  padding: 10px 16px 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #f0f0f0;
}

.day-row:last-child {
  border-bottom: none;
}

.day-row.has-active {
  background: #f8f8f8;
}

.day-label {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  min-width: 56px;
}

/* Scan Items (pill buttons) */
.day-scans {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.scan-item {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  background: #e8e8e8;
  color: #555;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.1s ease;
}

.scan-item:hover {
  background: #d0d0d0;
  color: #333;
}

.scan-item.active {
  background: #111;
  color: #fff;
}

/* Overlay for dropdown */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.3);
  z-index: 999;
  display: none;
}

.overlay.open {
  display: block;
}

/* Main Content */
.scan-container {
  flex: 1;
}

#scan-content {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
}

/* Loading State */
.loading {
  padding: 60px;
  text-align: center;
  color: #666;
  font-size: 14px;
}

/* Error State */
.error {
  padding: 60px;
  text-align: center;
}

.error h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.error p {
  color: #666;
  font-size: 14px;
}

/* No Scan State */
.no-scan {
  padding: 80px 40px;
  text-align: center;
}

.no-scan h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.no-scan p {
  color: #666;
  font-size: 14px;
}

/* Scan selector bar (when multiple scans per day) */
.scan-selector {
  padding: 12px 16px;
  background: #fafafa;
  border-bottom: 1px solid #e8e8e8;
  display: flex;
  align-items: center;
  gap: 8px;
}

.scan-selector-label {
  font-size: 11px;
  font-weight: 500;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.scan-selector-pills {
  display: flex;
  gap: 6px;
}

.scan-pill {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  background: #e8e8e8;
  color: #555;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.1s ease;
}

.scan-pill:hover {
  background: #d8d8d8;
  color: #333;
}

.scan-pill.active {
  background: #111;
  color: #fff;
}

/* Embedded scan overrides */
#scan-content .container {
  border: none;
  max-width: none;
  background: #ffffff;
}

/* Hide the scan's header when embedded - site header is sufficient */
#scan-content .container > .header {
  display: none;
}

/* Ensure table wrapper starts at top with no gap */
#scan-content .container > .table-wrapper {
  margin-top: 0;
}

#scan-content .header-left h1 {
  font-size: 16px;
  font-weight: 700;
  color: #111;
  letter-spacing: -0.3px;
}

#scan-content .header-left .subtitle {
  font-size: 11px;
  color: #666;
  font-weight: 500;
  margin-top: 2px;
}

#scan-content .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

#scan-content .date {
  font-size: 12px;
  color: #666;
  font-weight: 500;
}

#scan-content .count {
  font-size: 11px;
  font-weight: 600;
  color: #666;
  background: #f8f8f8;
  padding: 4px 8px;
  border: 1px solid #e8e8e8;
}

#scan-content .table-wrapper {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 70vh;
  position: relative; /* helps sticky stacking */
}

#scan-content table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

#scan-content thead th {
  padding: 10px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 5;
  background: #f8f8f8;
  border-bottom: 1px solid #e8e8e8;
}

/* Kill the pseudo-background from generated HTML */
#scan-content thead th::after {
  content: none !important;
}

#scan-content thead th:first-child { padding-left: 16px; }
#scan-content thead th:last-child { padding-right: 16px; }
#scan-content thead th:hover { background: #f0f0f0; }

#scan-content thead th .sort-arrow {
  margin-left: 3px;
  opacity: 0.3;
  font-size: 9px;
}

#scan-content thead th.sorted .sort-arrow { opacity: 1; }

#scan-content tbody tr {
  border-bottom: 1px solid #e8e8e8;
}

#scan-content tbody tr:nth-child(even) { background: #fafafa; }
#scan-content tbody tr:hover { background: #f5f5f5; }

#scan-content tbody td {
  padding: 8px 12px;
  font-size: 12px;
  color: #333;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

#scan-content tbody td:first-child { padding-left: 16px; }
#scan-content tbody td:last-child { padding-right: 16px; }

#scan-content .ticker { font-weight: 700; color: #111; }
#scan-content .name { font-size: 11px; color: #666; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
#scan-content .price { font-weight: 600; color: #111; }
#scan-content .liq { font-size: 11px; color: #666; }
#scan-content .adr { color: #666; }
#scan-content .rank { color: #666; font-size: 11px; }

/* RS Badge */
#scan-content .rs-badge {
  display: inline-block;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  min-width: 32px;
  text-align: center;
}

#scan-content .rs-elite { background: #16a34a; color: #ffffff; }
#scan-content .rs-high { background: #16a34a; color: #ffffff; }
#scan-content .rs-mid { background: #fbbf24; color: #422006; }
#scan-content .rs-low { background: #e5e5e5; color: #737373; }

/* BIS colors */
#scan-content .bis-strong { color: #16a34a; font-weight: 700; }
#scan-content .bis-moderate { color: #d97706; font-weight: 600; }
#scan-content .bis-weak { color: #9ca3af; }

/* RVol colors */
#scan-content .rvol-high { color: #16a34a; font-weight: 600; }
#scan-content .rvol-mid { color: #d97706; font-weight: 600; }
#scan-content .rvol-low { color: #9ca3af; }

/* Contraction colors */
#scan-content .contr-high { color: #16a34a; font-weight: 600; }
#scan-content .contr-mid { color: #d97706; font-weight: 600; }
#scan-content .contr-low { color: #9ca3af; }

/* DCR colors */
#scan-content .dcr-high { color: #16a34a; font-weight: 600; }
#scan-content .dcr-mid { color: #d97706; font-weight: 600; }
#scan-content .dcr-low { color: #9ca3af; }

/* % From Open colors */
#scan-content .from-open-high { color: #16a34a; font-weight: 600; }
#scan-content .from-open-mid { color: #6b7280; }
#scan-content .from-open-neg { color: #dc2626; font-weight: 600; }

/* Tooltip styles for embedded scans */
#scan-content .has-tooltip {
  /* FIX: Removed position: relative to avoid overriding sticky on th */
}

#scan-content .has-tooltip .tooltip {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 8px;
  padding: 10px 12px;
  background: #1f2937;
  color: #ffffff;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.5;
  text-transform: none;
  letter-spacing: 0;
  white-space: normal;
  width: 260px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
  transition: opacity 0.15s ease;
}

#scan-content .has-tooltip .tooltip::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: #1f2937;
}

#scan-content .has-tooltip:hover .tooltip {
  visibility: visible;
  opacity: 1;
}

#scan-content .tooltip-title {
  font-weight: 600;
  margin-bottom: 4px;
  display: block;
  font-size: 11px;
}

/* Right-align tooltip for last column */
#scan-content th:last-child.has-tooltip .tooltip {
  left: auto;
  right: 0;
  transform: none;
}

#scan-content th:last-child.has-tooltip .tooltip::before {
  left: auto;
  right: 16px;
  transform: none;
}

/* Footer */
.site-footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #666;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.footer-links a {
  color: #666;
  text-decoration: none;
  font-weight: 600;
  transition: color 0.15s ease;
}

.footer-links a:hover {
  color: #111;
}

.separator {
  color: #666;
  font-weight: 600;
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .site-container {
    padding: 16px;
  }

  .site-header {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }

  .header-title h1 {
    font-size: 20px;
  }

  .site-footer {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
}
