* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: "Inter", sans-serif;
}

/* Enhanced scrollbar for ranked grid */
#ranked-grid {
  padding: 3px 0;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  will-change: scroll-position;
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 800px;
  position: relative;
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
}

/* Scroll hint indicator for mobile */
#ranked-grid::after {
  content: '';
  position: sticky;
  right: 0;
  top: 0;
  height: 100%;
  width: 30px;
  background: linear-gradient(90deg, transparent, rgba(248, 250, 252, 0.95));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 5;
}

@media (max-width: 768px) {
  #ranked-grid::after {
    opacity: 1; /* Show scroll hint on mobile */
  }
}

#ranked-grid::-webkit-scrollbar {
  width: 8px;
}

#ranked-grid::-webkit-scrollbar-track {
  background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
  border-radius: 8px;
  margin: 3px 2px;
}

#ranked-grid::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #94a3b8, #64748b);
  border-radius: 8px;
  border: 2px solid #f1f5f9;
  transition: all 0.3s ease;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.1);
}

#ranked-grid::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #64748b, #475569);
  border-color: #e2e8f0;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

/* --- GRID CONFIGURATION --- */
.grid-container {
  display: grid;
  /* Columns: Symbol | Call1 Buy | Call1 Sell | Call2 Buy | Call2 Sell | Call3 GO */
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr;
  font-size: 0.64rem;
  align-items: center;
}

/* Ranked grid with 8 columns including rank and pin */
.ranked-grid-container {
  display: grid;
  /* Columns: Rank | Symbol | Call1 Buy | Call1 Sell | Call2 Buy | Call2 Sell | Call3 GO | Pin */
  grid-template-columns: 0.5fr 2fr 1fr 1fr 1fr 1fr 1fr 0.5fr;
  font-size: var(--grid-font-size, 0.625rem);
  align-items: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
  position: relative;
  margin: 1.5px 2px;
  border-radius: 5px;
  min-width: 380px;
}

.ranked-grid-container:not(:first-child):hover {
  transform: translateX(3px) scale(1.005);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.9), rgba(248, 250, 252, 0.9)) !important;
  z-index: 5;
}

.ranked-grid-container:not(:first-child) {
  backdrop-filter: blur(8px);
}

/* Page 2 grid with 8 signal columns */
.page2 .grid-container {
  /* Columns: Trend | Symbol | Call1 Buy | Call1 Sell | Call2 Buy | Call2 Sell | Call3 Buy | Call3 Sell */
  grid-template-columns: 1fr 2fr 1fr 1fr 1fr 1fr 1fr 1fr;
}

/* --- ANIMATIONS --- */
.highlight-signal {
  animation: highlight-fade 15s ease-out forwards;
}
@keyframes highlight-fade {
  0% { background-color: rgba(239, 68, 68, 0.4); }
  50% { background-color: rgba(34, 197, 94, 0.4); }
  100% { background-color: transparent; }
}

.long-term-highlight {
  animation: long-term-flash 1s ease-out 3;
}
@keyframes long-term-flash {
  0%, 100% { background-color: transparent; }
  50% { background-color: rgba(234, 179, 8, 0.8); }
}

/* --- UNIFIED SYMBOL FLASHING (SLOWER) --- */
.flash-green {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.95), rgba(22, 163, 74, 0.9)) !important;
  color: white !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.3) !important;
  animation: glow-green 2s ease-in-out infinite;
}
.flash-red {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.95), rgba(220, 38, 38, 0.9)) !important;
  color: white !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.3) !important;
  animation: glow-red 2s ease-in-out infinite;
}

@keyframes glow-green {
  0%, 100% { box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.3); }
  50% { box-shadow: 0 6px 20px rgba(34, 197, 94, 0.6), inset 0 1px 2px rgba(255, 255, 255, 0.4); }
}

@keyframes glow-red {
  0%, 100% { box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.3); }
  50% { box-shadow: 0 6px 20px rgba(239, 68, 68, 0.6), inset 0 1px 2px rgba(255, 255, 255, 0.4); }
}

/* Dark brown indicator for dual interval matches */
.dual-match-indicator {
  background: linear-gradient(135deg, #7c2d12, #92400e);
  border-radius: 50%;
  width: 12px;
  height: 12px;
  box-shadow: 0 2px 4px rgba(124, 45, 18, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.2);
}

/* Enhanced cell styling for data cells */
.ranked-grid-container > div {
  position: relative;
  transition: all 0.2s ease;
  height: var(--grid-row-height, 32px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ranked-grid-container:not(:first-child) > div:not(.pinned-row)::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.ranked-grid-container:not(:first-child):hover > div::after {
  animation: cell-shimmer 1.5s ease-in-out;
}

@keyframes cell-shimmer {
  0% { opacity: 0; transform: translateX(-100%); }
  50% { opacity: 1; }
  100% { opacity: 0; transform: translateX(100%); }
}

/* --- STATIC PERSISTENCE (After 20 Mins) --- */
.static-green {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.85), rgba(22, 163, 74, 0.9)) !important;
  color: white !important;
  border-radius: 8px !important;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3) !important;
}
.static-red {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.85), rgba(220, 38, 38, 0.9)) !important;
  color: white !important;
  border-radius: 8px !important;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3) !important;
}
.static-green .strong-badge, .static-red .strong-badge {
   color: #1f2937 !important;
}

.tooltip {
  visibility: hidden;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  pointer-events: none;
  transform: translateY(5px) scale(0.9);
  backdrop-filter: blur(10px);
  background: linear-gradient(135deg, rgba(17, 24, 39, 0.95), rgba(31, 41, 55, 0.95)) !important;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.has-tooltip:hover .tooltip {
  visibility: visible;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Per-Row Mute Button */
.mute-btn {
    cursor: pointer;
    opacity: 0.3;
    transition: opacity 0.2s;
    padding: 4px;
    border-radius: 4px;
}
.mute-btn:hover { opacity: 1; background-color: #f3f4f6; }
.mute-btn.muted { opacity: 1; color: red; }

/* Per-Row Pause Button (Icon Only) */
.stop-row-btn {
    cursor: pointer;
    opacity: 0.7;
    font-size: 0.8rem;
    margin-left: 8px;
    padding: 4px 8px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 9999px;
    color: #4b5563;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: all 0.2s;
}
.stop-row-btn:hover { 
    background: #f3f4f6; 
    color: #1f2937;
    transform: scale(1.05);
}

/* Match row highlighting for all matching signals */
.match-row-buy {
  background: linear-gradient(120deg, rgba(34, 197, 94, 0.12) 0%, rgba(34, 197, 94, 0.05) 50%, rgba(34, 197, 94, 0.08) 100%) !important;
  transition: all 0.3s ease;
}

.match-row-sell {
  background: linear-gradient(120deg, rgba(239, 68, 68, 0.12) 0%, rgba(239, 68, 68, 0.05) 50%, rgba(239, 68, 68, 0.08) 100%) !important;
  transition: all 0.3s ease;
}

/* Strong row highlighting for dual matches */
.strong-row-buy {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.25) 0%, rgba(34, 197, 94, 0.15) 100%) !important;
  border: 2px solid rgba(34, 197, 94, 0.9) !important;
  border-radius: 10px !important;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3), inset 0 1px 2px rgba(255, 255, 255, 0.5) !important;
  position: relative;
  overflow: hidden;
}

.strong-row-buy::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: slide-shine 3s infinite;
}

.strong-row-sell {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.25) 0%, rgba(239, 68, 68, 0.15) 100%) !important;
  border: 2px solid rgba(239, 68, 68, 0.9) !important;
  border-radius: 10px !important;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3), inset 0 1px 2px rgba(255, 255, 255, 0.5) !important;
  position: relative;
  overflow: hidden;
}

.strong-row-sell::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: slide-shine 3s infinite;
}

@keyframes slide-shine {
  0% { left: -100%; }
  100% { left: 200%; }
}

.strong-row-buy .bg-white,
.strong-row-buy .bg-gray-50,
.strong-row-buy .bg-amber-50,
.strong-row-buy .bg-amber-100\/60,
.strong-row-buy .bg-blue-50,
.strong-row-buy .bg-blue-100\/60,
.strong-row-sell .bg-white,
.strong-row-sell .bg-gray-50,
.strong-row-sell .bg-amber-50,
.strong-row-sell .bg-amber-100\/60,
.strong-row-sell .bg-blue-50,
.strong-row-sell .bg-blue-100\/60 {
  background: transparent !important;
}

/* "STRONG" Badge - Cylindrical/Pill Shape */
.strong-badge {
    font-size: 0.5rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 9999px;
    margin-left: 5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background-color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.15), 0 1px 2px rgba(0,0,0,0.1);
    animation: pulse-badge 2s ease-in-out infinite;
    border-width: 1.5px;
    display: inline-block;
    position: relative;
    overflow: hidden;
}

.strong-badge::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.5) 50%, transparent 70%);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.badge-buy {
    color: #166534;
    border-color: #22c55e;
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    text-shadow: 0 1px 2px rgba(22, 101, 52, 0.1);
}
.badge-sell {
    color: #991b1b;
    border-color: #ef4444;
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    text-shadow: 0 1px 2px rgba(153, 27, 27, 0.1);
}

@keyframes pulse-badge {
    0% { transform: scale(1); box-shadow: 0 4px 8px rgba(0,0,0,0.15), 0 2px 4px rgba(0,0,0,0.1); }
    50% { transform: scale(1.08); box-shadow: 0 6px 12px rgba(0,0,0,0.2), 0 3px 6px rgba(0,0,0,0.15); }
    100% { transform: scale(1); box-shadow: 0 4px 8px rgba(0,0,0,0.15), 0 2px 4px rgba(0,0,0,0.1); }
}

/* Floating Global Controls */
.floating-controls {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}

.control-btn {
    padding: 8px 16px;
    color: white;
    font-weight: bold;
    font-size: 0.8rem;
    border-radius: 9999px;
    box-shadow: 0 3px 5px -1px rgba(0, 0, 0, 0.1), 0 2px 3px -1px rgba(0, 0, 0, 0.06);
    transition: transform 0.1s, background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    border: none;
    cursor: pointer;
    min-width: 128px;
    justify-content: center;
    font-family: 'Inter', sans-serif;
}

.btn-stop { background-color: #ef4444; }
.btn-stop:hover { background-color: #dc2626; transform: scale(1.02); }

.btn-pause { background-color: #f59e0b; }
.btn-pause:hover { background-color: #d97706; transform: scale(1.02); }

.btn-resume { background-color: #3b82f6; }
.btn-resume:hover { background-color: #2563eb; transform: scale(1.02); }

.control-btn:active { transform: scale(0.98); }

/* --- DRAG AND DROP STYLING --- */
.pinned-row {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  cursor: move;
  user-select: none;
  border-radius: 8px;
}

/* Left border styling for all pinned rows - positioned to not affect layout */
.pinned-row::before {
  content: '';
  position: absolute;
  left: -2px; /* Position outside to avoid pushing content */
  top: 0;
  bottom: 0;
  width: 4px;
  animation: gradient-shift 3s ease infinite;
  border-radius: 4px 0 0 4px;
  z-index: 1;
}

/* Blue border for non-strong pinned rows */
.pinned-row:not(.strong-row-buy):not(.strong-row-sell)::before {
  background: linear-gradient(180deg, #3b82f6, #60a5fa, #3b82f6);
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}

/* Green border for strong buy pinned rows */
.pinned-row.strong-row-buy::before {
  background: linear-gradient(180deg, #22c55e, #16a34a, #22c55e);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

/* Red border for strong sell pinned rows */
.pinned-row.strong-row-sell::before {
  background: linear-gradient(180deg, #ef4444, #dc2626, #ef4444);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

@keyframes gradient-shift {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.pinned-row.dragging {
  opacity: 0.6 !important;
  transform: scale(0.98) rotate(2deg);
  box-shadow: 0 12px 24px rgba(59, 130, 246, 0.4), 0 0 0 2px #3b82f6;
  z-index: 1000;
  border: 2px dashed #60a5fa !important;
  background: rgba(239, 246, 255, 0.95) !important;
}

.pinned-row.drag-over {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(147, 197, 253, 0.08) 100%) !important;
  border-top: 3px solid #60a5fa !important;
  border-bottom: 3px solid #60a5fa !important;
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.35), inset 0 0 20px rgba(59, 130, 246, 0.1);
  animation: pulse-drag 1s ease-in-out infinite;
}

@keyframes pulse-drag {
  0%, 100% {
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.35), inset 0 0 20px rgba(59, 130, 246, 0.1);
    transform: translateY(-3px) scale(1.02);
  }
  50% {
    box-shadow: 0 12px 28px rgba(59, 130, 246, 0.45), inset 0 0 30px rgba(59, 130, 246, 0.15);
    transform: translateY(-4px) scale(1.03);
  }
}

.drag-handle {
    display: none;
}

/* Modern header styling */
.ranked-grid-container:first-child {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  border-radius: 8px 8px 0 0;
  margin: 0 2px;
}

.ranked-grid-container:first-child > div {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.48rem;
  padding: 8px !important;
  height: auto !important; /* Override dynamic height for header */
}

/* Symbol column left-align */
.ranked-grid-container > div:nth-child(2) {
  justify-content: flex-start !important;
  padding-left: 8px;
}

/* Rank badge styling */
.ranked-grid-container > div:first-child > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 5px;
  font-weight: 700;
  font-size: 0.56rem;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.ranked-grid-container:not(:first-child):hover > div:first-child > span {
  transform: scale(1.2) rotate(8deg);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Top 3 ranks get special styling based on actual rank */
.rank-gold {
  background: linear-gradient(135deg, #fbbf24, #f59e0b) !important;
  color: white !important;
  box-shadow: 0 1px 5px rgba(251, 191, 36, 0.4);
}

.rank-silver {
  background: linear-gradient(135deg, #94a3b8, #64748b) !important;
  color: white !important;
  box-shadow: 0 1px 5px rgba(148, 163, 184, 0.4);
}

.rank-bronze {
  background: linear-gradient(135deg, #d97706, #92400e) !important;
  color: white !important;
  box-shadow: 0 1px 5px rgba(217, 119, 6, 0.4);
}

/* Pin Button Styling */
.pin-toggle-btn {
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 2px;
    border-radius: 4px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    position: relative;
    overflow: hidden;
}

.pin-toggle-btn .material-symbols-outlined {
    font-size: 0.8rem;
}

.pin-toggle-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(147, 197, 253, 0.1));
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 8px;
}

.pin-toggle-btn:hover {
    background: linear-gradient(135deg, #f3f4f6, #f9fafb);
    color: #6b7280;
    transform: scale(1.15) rotate(5deg);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.pin-toggle-btn:hover::before {
    opacity: 1;
}

.pin-toggle-btn.pinned {
    color: #3b82f6;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.pin-toggle-btn.pinned:hover {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    color: #2563eb;
    transform: scale(1.15) rotate(-5deg);
    box-shadow: 0 6px 12px rgba(59, 130, 246, 0.3);
}

.pin-toggle-btn.pinned::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.6) 50%, transparent 70%);
    animation: shimmer 2s infinite;
    border-radius: 8px;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Chart Container and Tooltip Styling */
#percent-change-chart {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 200px;
}

#percent-change-chart canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Ensure left panel has proper dimensions */
#left-panel {
  position: relative;
  min-height: 300px;
}

/* Right panel scrolling */
#right-panel {
  display: flex;
  flex-direction: column;
}


/* Zoom level indicator */
.zoom-indicator {
  font-size: 10px;
  color: #64748b;
  text-align: center;
  margin-top: 2px;
}

.chart-tooltip {
  position: fixed !important;
  z-index: 99999 !important;
  pointer-events: auto !important;
  border-radius: 8px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.2), 0 8px 16px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(12px);
  min-width: 224px;
  max-width: 400px;
  width: max-content;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: top left;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden;
  font-size: 0.8rem;
}

/* Responsive tooltip sizing */
@media (max-width: 768px) {
  .chart-tooltip {
    min-width: 192px;
    max-width: 90vw;
    border-radius: 6px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2), 0 4px 8px rgba(0, 0, 0, 0.15);
  }
}

@media (max-width: 480px) {
  .chart-tooltip {
    min-width: 160px;
    max-width: 95vw;
    border-radius: 5px;
    font-size: 0.72rem;
  }
}

.chart-tooltip > div:first-child {
  position: relative;
  overflow: hidden;
}

.chart-tooltip > div:first-child::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shimmer-header 3s infinite;
}

@keyframes shimmer-header {
  0% { left: -100%; }
  100% { left: 200%; }
}

.chart-tooltip .tooltip-body {
  max-height: 360px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.4) transparent;
}

.chart-tooltip .tooltip-body::-webkit-scrollbar {
  width: 5px;
}

.chart-tooltip .tooltip-body::-webkit-scrollbar-track {
  background: transparent;
  margin: 4px 0;
}

.chart-tooltip .tooltip-body::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: 3px;
  transition: background 0.2s;
}

.chart-tooltip .tooltip-body::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.6);
}

/* Chart Filter Buttons */
.chart-filter-btn {
  position: relative;
  overflow: hidden;
}

.chart-filter-btn.active {
  background: linear-gradient(135deg, #dbeafe, #bfdbfe) !important;
  color: #1e40af !important;
  border-color: #60a5fa !important;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.chart-filter-btn:not(.active):hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.chart-filter-btn.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: shimmer-filter 2s infinite;
}

@keyframes shimmer-filter {
  0% { left: -100%; }
  100% { left: 200%; }
}

/* Responsive filter buttons for small screens */
@media (max-width: 640px) {
  .chart-filter-btn {
    padding: 6px 10px !important;
    font-size: 9px !important;
  }
}

@media (max-width: 420px) {
  .chart-filter-btn {
    padding: 5px 8px !important;
    font-size: 8px !important;
  }
}

@media (max-width: 360px) {
  /* Stack filter buttons vertically on very small screens */
  #left-panel .absolute.top-4.right-4 {
    flex-direction: column !important;
    gap: 4px !important;
  }

  .chart-filter-btn {
    width: 100%;
    padding: 6px 12px !important;
    font-size: 9px !important;
  }
}

/* Zoom Controls Styling */
.zoom-btn {
  user-select: none;
  -webkit-user-select: none;
}

.zoom-btn:active {
  transform: scale(0.95);
}

/* Responsive layout for chart panels */
@media (min-width: 1025px) {
  /* Large screens - ensure proper full-height layout */
  main {
    height: calc(100vh - 52px) !important;
    margin-top: 52px !important;
    padding: 12px !important;
  }

  #left-panel {
    height: 100% !important;
    width: 70% !important;
    min-width: 400px !important;
  }

  #right-panel {
    height: 100% !important;
    flex: 1 !important;
  }
}

@media (max-width: 1024px) {
  main {
    height: calc(100vh - 52px) !important;
    margin-top: 52px !important;
    padding: 10px !important;
  }

  #left-panel {
    min-width: 280px !important;
    width: 60% !important;
    height: 100% !important;
  }

  #right-panel {
    height: 100% !important;
  }

  #divider {
    width: 13px !important;
    margin: 0 6px !important;
  }
}

@media (max-width: 768px) {
  main {
    flex-direction: column !important;
    gap: 10px !important;
    height: calc(100vh - 52px) !important;
    margin-top: 52px !important;
    padding: 8px !important;
  }

  #left-panel {
    width: 100% !important;
    min-height: 45vh !important;
    max-height: 50vh !important;
    height: 45vh !important;
    flex-shrink: 0 !important;
  }

  #divider {
    display: none !important;
  }

  #right-panel {
    width: 100% !important;
    height: auto !important;
    flex: 1 !important;
    min-height: 0 !important;
  }

  /* Increase grid font size on tablets */
  .ranked-grid-container {
    font-size: 0.7rem; /* 11.2px */
  }

  .ranked-grid-container:first-child > div {
    font-size: 0.56rem; /* Header slightly larger */
  }

  /* Enable horizontal scroll for grid on tablets */
  #ranked-grid {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Show scrollbar on mobile for grid */
  #ranked-grid::-webkit-scrollbar {
    height: 6px;
  }

  #ranked-grid::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
  }

  #ranked-grid::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, #94a3b8, #64748b);
    border-radius: 3px;
  }

  /* Zoom controls positioning for tablets */
  #left-panel .absolute.bottom-4.right-4 {
    bottom: 8px !important;
    right: 8px !important;
  }

  .zoom-btn {
    width: 28px !important;
    height: 28px !important;
    font-size: 14px !important;
  }
}

@media (max-width: 480px) {
  main {
    padding: 6px !important;
    margin-top: 52px !important;
    height: calc(100vh - 52px) !important;
    gap: 6px !important;
  }

  #left-panel {
    min-height: 40vh !important;
    max-height: 45vh !important;
    height: 42vh !important;
  }

  #right-panel {
    flex: 1 !important;
  }

  /* Further increase font size on mobile */
  .ranked-grid-container {
    font-size: 0.75rem; /* 12px - more readable */
    margin: 2px 1px; /* Tighter margins */
  }

  .ranked-grid-container:first-child > div {
    font-size: 0.6rem;
    padding: 6px 4px !important; /* Tighter header padding */
  }

  /* Reduce grid column padding on mobile */
  .ranked-grid-container > div {
    padding: 6px 4px;
  }

  /* Adjust rank badge size */
  .ranked-grid-container > div:first-child > span {
    min-width: 16px;
    height: 16px;
    font-size: 0.5rem;
  }

  /* Pin button sizing */
  .pin-toggle-btn .material-symbols-outlined {
    font-size: 0.7rem;
  }
}

@media (max-width: 360px) {
  main {
    padding: 4px !important;
    margin-top: 52px !important;
    height: calc(100vh - 52px) !important;
    gap: 4px !important;
  }

  #left-panel {
    min-height: 38vh !important;
    max-height: 42vh !important;
    height: 40vh !important;
  }

  .ranked-grid-container {
    font-size: 0.7rem; /* 11.2px - balance between size and readability */
  }

  .ranked-grid-container:first-child > div {
    font-size: 0.55rem;
  }
}

/* Additional mobile optimizations */
@media (max-width: 640px) {
  /* Optimize header spacing on mobile */
  .fixed.top-0 {
    padding: 6px 12px !important;
  }

  /* Ensure chart container doesn't overflow */
  #percent-change-chart {
    touch-action: pan-y; /* Allow vertical scrolling only */
  }

  /* Improve tooltip positioning on mobile */
  .chart-tooltip {
    max-height: 80vh !important;
    overflow-y: auto !important;
  }

  /* Optimize floating controls for mobile */
  .floating-controls {
    bottom: 12px;
    right: 12px;
    gap: 6px;
  }

  .control-btn {
    padding: 6px 12px;
    font-size: 0.7rem;
    min-width: 100px;
  }
}

/* ================================ */
/* PAGE 2 SPECIFIC STYLES          */
/* ================================ */

/* Page 2 Grid - Compact layout for max signals */
.page2 .grid-container {
  display: grid;
  grid-template-columns: 50px 100px repeat(6, 1fr);
  font-size: 10px;
  min-width: 500px;
}

.page2 .grid-container.grid-header {
  position: sticky;
  top: 0;
  z-index: 10;
}

.page2 .grid-container.grid-row:hover {
  background: #eff6ff !important;
}

/* Empty State */
.page2 .grid-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: #94a3b8;
}

.page2 .grid-empty-state .material-symbols-outlined {
  font-size: 40px;
  margin-bottom: 8px;
  opacity: 0.5;
}

/* Responsive */
@media (max-width: 768px) {
  .page2 .grid-container {
    font-size: 9px;
    min-width: 450px;
    grid-template-columns: 45px 80px repeat(6, 1fr);
  }
}

@media (max-width: 640px) {
  .page2 .grid-container {
    font-size: 8px;
    min-width: 400px;
    grid-template-columns: 40px 70px repeat(6, 1fr);
  }
}