/* ---------------------------------------------------
   HOME TAB STYLING
--------------------------------------------------- */

.favorite-item {
  display: flex;
  align-items: center;
  padding: 12px;
  background: #1b1b1b;
  margin-bottom: 10px;
  border-radius: 10px;
}

.favorite-item img {
  width: 48px;
  height: 48px;
  margin-right: 12px;
  border-radius: 6px;
}

.favorite-info h3 {
  margin: 0;
}

/* sparkline-container moved to components.css */

.favorite-stats {
  font-size: 14px;
  color: #4b9cd3;
}

.feed-item {
  padding: 8px 0;
  border-bottom: 1px solid #333;
  color: #ccc;
}

/* ---------------------------------------------------
   DASHBOARD SECTIONS
--------------------------------------------------- */
.dashboard-section {
  display: flex;
  flex-direction: column;
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0;
}

/* Split Layout: row height is viewport-capped so the watchlist scrolls inside instead of growing the page */
.home-split-layout {
  display: flex;
  flex-direction: row;
  gap: 24px;
  width: 100%;
  margin-bottom: 24px;
  align-items: stretch;
  min-height: min(500px, 50vh);
  max-height: calc(100vh - 160px);
  overflow: hidden;
  height: clamp(650px, 75vh, calc(100vh - 100px));
}

/* Common Panel Styling — solid fill (no diagonal gradient from --theme-home-column-bg) */
.home-chart-column,
.home-pinned-column {
  background: var(--theme-bg-surface);
  border: 1px solid var(--theme-home-column-border);
  border-radius: var(--theme-tab-surface-radius, 12px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--theme-home-column-shadow);
  overflow: hidden; /* Ensure rounded corners clip content */
  min-height: 0; /* allow shrinking inside max-height split row */
}

.home-chart-column {
  flex: 3;
  min-width: 0;
}

.home-pinned-column {
  flex: 2;
  min-width: 0;
}

/* Panel Header */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--theme-panel-header-bg);
    border-bottom: 1px solid var(--theme-panel-header-border);
}

.home-chart-column .panel-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
}

.home-chart-column .panel-header > * {
    min-width: 0;
}

.home-chart-column .panel-header h3 {
    justify-self: start;
}

.home-chart-column .panel-header .time-range-selector {
    justify-self: center;
    margin-bottom: 0; /* Override component style */
}

.home-chart-column .panel-header .panel-actions {
    justify-self: end;
}

.panel-header h3 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--theme-panel-title-color);
}

.panel-subtitle {
    font-size: 0.8rem;
    color: var(--theme-text-panel-subtitle);
    margin-left: 10px;
    font-weight: 500;
}

.panel-subtitle .pin-link {
    color: var(--theme-text-pin-link);
    text-decoration: none;
}

.panel-subtitle .pin-link:hover {
    color: var(--theme-text-pin-link-hover);
    text-decoration: underline;
}

/* Panel Actions (Toolbar in Header) */
.panel-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Override overrides for nested components to fit header */
.panel-actions .hobby-select-dropdown {
    height: 30px;
    padding: 0 24px 0 10px;
    font-size: 0.8rem;
    background-color: #111;
    border-color: #444;
}

.panel-actions .range-btn,
.home-chart-column .panel-header .time-range-selector button {
    padding: 4px 10px;
    font-size: 0.75rem;
    height: 28px;
}

.panel-actions .legend-toggle-btn {
    height: 30px;
    padding: 0 12px;
    font-size: 0.9rem;
    background: transparent;
    border: 1px solid #444;
    color: #aaa;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.panel-actions .legend-toggle-btn:hover {
    color: #fff;
    border-color: #666;
    background: rgba(255,255,255,0.05);
}

#homePinnedMetricSelectorContainer {
    /* Home pinned: modest fixed width so header layout stays intact */
    width: 220px;
    min-width: 0;
    flex-shrink: 0;
}

.home-pinned-trend-line-wrap {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-shrink: 0;
}

.home-trend-line-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--theme-text-panel-subtitle, #111827);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.home-trend-line-label input {
    margin: 0;
    cursor: pointer;
}

/* Metric Selector */
.metric-selector-group {
    display: flex;
    gap: 4px;
    background: #111;
    padding: 2px;
    border-radius: 6px;
    border: 1px solid #444;
}

.metric-btn {
    background: transparent;
    border: none;
    color: #888;
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    text-transform: uppercase;
}

.metric-btn:hover {
    color: #ccc;
    background: rgba(255, 255, 255, 0.05);
}

.metric-btn.active {
    background: #4b9cd3;
    color: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Chart Container Overrides */
.home-chart-column .chart-container {
    flex: 1 1 0%;
    min-height: 0;
    width: 100%;
    position: relative;
    /* Reset generic chart-container styles to avoid nesting boxes */
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 20px;
    margin: 0;
}

/* Loading Overlay */
.chart-loading-overlay, .chart-error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(30, 30, 30, 0.8);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    color: #ccc;
    font-family: 'Montserrat', sans-serif;
}

/* Metric Selector Embedded in Chart - Removed as moved to panel header */
/* .chart-embedded-selector { ... } */

.chart-error-overlay i {
    font-size: 2rem;
    color: #fc8181;
    margin-bottom: 8px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #4b9cd3;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Pinned list: flex-basis 0 + min-height 0 so this region scrolls inside the capped column */
#homePinnedCardsScroll.pinned-list-scroll-area {
    flex: 1 1 0%;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 10px;
}

#homeDefaultOverviewsMount {
    flex-shrink: 0;
}

/* Legacy class name — keep for any older references */
.pinned-list-scroll-area {
    flex: 1 1 0%;
    min-height: 0;
    overflow-y: auto;
    padding: 10px;
}

.home-pinned-panel-header {
    flex-shrink: 0;
}

.home-pinned-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.home-add-pin-group-btn {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--theme-border-pinned-row, #444);
    background: rgba(75, 156, 211, 0.12);
    color: var(--theme-accent-primary, #4b9cd3);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.home-add-pin-group-btn:hover {
    background: rgba(75, 156, 211, 0.22);
    border-color: var(--theme-accent-primary, #4b9cd3);
}

/* User pin groups — same visual language as “Markets in this group” / default overviews */
.home-pin-group-card {
    margin-bottom: 12px;
    background: var(--theme-bg-default-overviews);
    border: 1px solid var(--theme-border-default-overviews);
    border-radius: 8px;
    overflow: hidden;
}

.home-pin-group-card:last-child {
    margin-bottom: 0;
}

.home-pin-group-details {
    width: 100%;
}

.home-pin-group-card__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--theme-text-home-default-summary, #e2e8f0);
    background: var(--theme-bg-home-default-summary, rgba(0, 0, 0, 0.2));
    border-bottom: 1px solid var(--theme-border-default-overviews);
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.home-pin-group-card__title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.home-pin-group-card__title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-pin-group-delete-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--theme-text-home-default-summary, #111827);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

.home-pin-group-delete-btn:hover {
    color: #f87171;
    background: rgba(248, 113, 113, 0.12);
}

.home-pin-group-card__summary-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    margin-left: auto;
}

.home-pin-group-card__summary::-webkit-details-marker {
    display: none;
}

.home-pin-group-details[open] .home-pin-group-card__chev {
    transform: rotate(180deg);
}

.home-pin-group-card__chev {
    font-size: 0.65rem;
    opacity: 0.65;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.home-pin-group-chart-switch {
    flex-shrink: 0;
}

.home-pin-group-card__body {
    padding: 10px 10px 8px;
}

.home-pin-group-card__body .pinned-market-row {
    margin-bottom: 8px;
}

.home-pin-group-card__body .pinned-market-row:last-child {
    margin-bottom: 0;
}

.home-pin-group-select {
    font-size: 0.7rem;
    max-width: 112px;
    padding: 2px 4px;
    border-radius: 4px;
    border: 1px solid var(--theme-border-pinned-row, #444);
    background: var(--theme-bg-pinned-row, #1a1a24);
    color: var(--theme-text-pinned-name, #e2e8f0);
    cursor: pointer;
}

/* Custom Scrollbar for pinned column */
.pinned-list-scroll-area::-webkit-scrollbar {
    width: 6px;
}
.pinned-list-scroll-area::-webkit-scrollbar-track {
    background: transparent;
}
.pinned-list-scroll-area::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}

/* Pinned Market Row (Refined) */
.pinned-market-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--theme-bg-pinned-row);
    border: 1px solid var(--theme-border-pinned-row);
    border-left: 3px solid var(--trend-color, var(--theme-accent-primary));
    border-radius: 6px;
    padding: 14px 16px;
    margin-bottom: 8px; /* Spacing between rows */
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.pinned-market-row:hover {
    transform: translateY(-2px);
    background-color: var(--theme-bg-pinned-row-hover);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    border-color: var(--theme-border-pinned-row-hover);
}

.pinned-market-row:last-child {
    margin-bottom: 0;
}

/* Default category overviews (always at bottom, toggle + collapsible) */
.home-default-overviews-panel {
    margin-top: 16px;
    padding: 12px 14px;
    border-top: 1px solid var(--theme-border-default-overviews);
    background: var(--theme-bg-default-overviews);
    border-radius: 8px;
}

.home-default-overviews-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.home-default-overviews-toggle-row .toggle-copy {
    flex: 1;
    min-width: 0;
}

.home-default-overviews-toggle-row .toggle-title {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--theme-home-default-title);
}

.home-default-overviews-toggle-row .toggle-hint {
    font-size: 0.75rem;
    color: var(--theme-home-default-hint);
    margin-top: 2px;
}

.home-default-switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

/* Full hit target: zero-size input meant clicks hit `.slider`, not the checkbox, so
   `<summary>` treated the click as non-interactive and toggled `<details>` instead of the box. */
.home-default-switch input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    inset: 0;
    cursor: pointer;
    z-index: 2;
}

.home-default-switch .slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    z-index: 1;
    background: var(--theme-home-default-switch-off);
    border-radius: 24px;
    transition: 0.2s;
}

.home-default-switch .slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--theme-home-default-switch-knob);
    border-radius: 50%;
    transition: 0.2s;
}

.home-default-switch input:checked + .slider {
    background: var(--theme-accent-primary);
}

.home-default-switch input:checked + .slider:before {
    transform: translateX(20px);
}

.home-default-switch input:indeterminate + .slider {
    background: var(--theme-home-default-switch-off);
    box-shadow: inset 0 0 0 2px var(--theme-accent-primary, #4b9cd3);
}

.home-default-switch input:indeterminate + .slider:before {
    transform: translateX(11px);
}

.home-default-overviews-details {
    margin-top: 4px;
}

.home-default-overviews-dropdown-summary {
    width: 96%;
    text-align: left;
    padding: 10px 12px;
    background: var(--theme-bg-home-default-summary);
    border: 1px solid var(--theme-border-home-default-summary);
    border-radius: 6px;
    color: var(--theme-text-home-default-summary);
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    list-style: none;
}

.home-default-overviews-summary-title {
    flex: 1;
    min-width: 0;
    text-align: left;
}

.home-default-overviews-summary-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    margin-left: auto;
}

.home-default-overview-group-master-switch {
    flex-shrink: 0;
}

/* Hide “toggle all” until the list is expanded (summary stays clickable) */
.home-default-overviews-details:not([open]) .home-default-overview-group-master-switch {
    display: none;
}

.home-default-overviews-dropdown-summary::-webkit-details-marker {
    display: none;
}

.home-default-overviews-dropdown-summary:hover {
    border-color: var(--theme-border-home-default-summary-hover);
    background: var(--theme-bg-home-default-summary-hover);
}

.home-default-overviews-details[open] > .home-default-overviews-dropdown-summary {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: transparent;
}

.home-default-overviews-dropdown-summary .chevron {
    transition: transform 0.2s ease;
    opacity: 0.7;
    font-size: 0.7rem;
}

.home-default-overviews-details[open] .chevron {
    transform: rotate(180deg);
}

.home-default-overviews-list-inner {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--theme-border-home-default-list);
    border-top: none;
    border-radius: 0 0 6px 6px;
    background: var(--theme-bg-home-default-list);
}

.home-default-overview-empty {
    padding: 12px;
    font-size: 0.85rem;
    color: var(--theme-text-home-default-empty);
    text-align: center;
}

.home-default-overview-item {
    padding: 10px 12px;
    font-size: 0.85rem;
    color: var(--theme-text-home-default-item);
    border-bottom: 1px solid var(--theme-border-home-default-item);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.home-default-overview-item:last-child {
    border-bottom: none;
}

.home-default-overview-item:hover {
    background: var(--theme-bg-home-default-item-hover);
}

.home-default-overview-item .home-default-overview-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-default-item-switch {
    position: relative;
    width: 32px;
    height: 18px;
    flex-shrink: 0;
    margin-left: auto;
    cursor: pointer;
}

.home-default-item-switch input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    inset: 0;
    cursor: pointer;
    z-index: 2;
}

.home-default-item-switch .slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    z-index: 1;
    background: #3f3f46;
    border-radius: 18px;
    transition: 0.2s;
}

.home-default-item-switch .slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background: #e2e8f0;
    border-radius: 50%;
    transition: 0.2s;
}

.home-default-item-switch input:checked + .slider {
    background: #4b9cd3;
}

.home-default-item-switch input:checked + .slider:before {
    transform: translateX(14px);
}

.pinned-row-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
    min-width: 0;
}

.pinned-market-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--theme-text-pinned-name);
    letter-spacing: 0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pinned-market-badges .data-quality-badges {
    font-size: 0.65rem;
    gap: 4px;
    margin-top: 2px;
}

.pinned-market-badges .data-quality-badge {
    padding: 1px 6px;
}

.pinned-market-metric {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.85rem;
    color: var(--theme-text-pinned-metric);
}

.pinned-row-right {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-left: 16px;
    flex-shrink: 0;
}

.pinned-change-badge {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--theme-bg-pinned-badge);
    letter-spacing: -0.5px;
}

.pinned-change-badge.positive {
    color: #68d391; /* Softer Green */
    background: rgba(104, 211, 145, 0.1);
}

.pinned-change-badge.negative {
    color: #fc8181; /* Soft Red */
    background: rgba(252, 129, 129, 0.1);
}

.pinned-change-badge.neutral {
    color: #cbd5e0;
    background: rgba(203, 213, 224, 0.1);
}

.pinned-actions {
    opacity: 0;
    transition: opacity 0.2s;
}

.pinned-market-row:hover .pinned-actions {
    opacity: 1;
}

.pin-action-btn {
    background: transparent;
    border: none;
    color: #718096;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px;
    transition: color 0.2s;
}

.pin-action-btn:hover {
    color: #fc8181;
}

@media (max-width: 900px) {
  .home-split-layout {
    flex-direction: column;
    margin-bottom: 32px;
    max-height: none;
    overflow: visible;
    min-height: 0;
    height: auto;
  }
  .home-chart-column, .home-pinned-column {
    width: 100%;
    flex: auto;
    max-height: none;
    min-height: 0;
  }

  .home-chart-column {
    flex: 0 0 auto;
  }
  /*
   * Stacked layout: parent column height is `auto`, so flex: 1 1 0% + min-height: 0 on the
   * chart container collapses the plot (Chart.js sees ~0 height / wrong width). Give the
   * canvas a definite block size like the global .chart-container, slightly tighter on phones.
   */
  .home-chart-column .chart-container {
    flex: 0 0 auto;
    min-height: clamp(260px, 52vh, 480px);
    height: clamp(260px, 52vh, 480px);
    max-height: min(520px, 62vh);
    padding: 12px 14px;
  }
  /* Cap watchlist height when stacked so long lists scroll instead of stretching the tab */
  .home-pinned-column {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    max-height: min(70vh, 640px);
    overflow: hidden;
  }
  #homePinnedCardsScroll.pinned-list-scroll-area {
    flex: 1 1 0%;
    min-height: 0;
    overflow-y: auto;
  }
  
  /* Stack actions on mobile */
  .panel-header {
      flex-direction: column;
      align-items: flex-start;
      gap: 12px;
      padding: 12px 16px;
  }
  
  .home-chart-column .panel-header {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
  }
  
  .home-chart-column .panel-header .time-range-selector {
      margin-bottom: 10px;
      align-self: flex-start;
  }

  .panel-actions {
      width: 100%;
      justify-content: flex-start;
      flex-wrap: wrap;
      gap: 10px;
  }
  
  /* Ensure selectors don't shrink too much */
  .panel-actions > div {
      flex-grow: 1;
  }
  
  .legend-wrapper {
      margin-left: auto; /* Push legend to right if possible */
  }
}


/* ---------------------------------------------------
   HOME MARKET HEADER
--------------------------------------------------- */
#homeMarketHeader {
    position: relative;
    display: block;
    margin-bottom: 20px;
}

#homeMarketHeader h2 {
  text-align: left;
  font-size: 1.8rem; /* even larger */
  font-weight: 900; /* maximum bold */
  margin-top: 0;
  margin-bottom: 24px;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  text-shadow: 0 4px 10px rgba(0, 0, 0, 0.8), 0 0 20px rgba(75, 156, 211, 0.4); /* glow effect */
  position: relative;
  display: block;
  width: 100%;
  padding-bottom: 12px;
  border-bottom: 4px solid var(--carolina-blue);
}

#homePinnedCardsList {
  min-height: 0;
}

.dashboard-section h2 {
  text-align: left;
  font-size: 1.8rem; /* slightly smaller than main title */
  font-weight: 800;
  margin-top: 16px;
  margin-bottom: 16px;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 0 3px 8px rgba(0, 0, 0, 0.7), 0 0 15px rgba(75, 156, 211, 0.3);
  position: relative;
  display: block;
  width: 100%;
  padding-bottom: 8px;
  border-bottom: 3px solid var(--carolina-blue);
}

/* ---------------------------------------------------
   MARKET FEED (HOTTEST MARKETS)
--------------------------------------------------- */
#homeMarketFeed {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-x: auto; /* Allow horizontal scroll on very small screens if table overflows */
}

/* Old Card Styles (kept for reference or fallback) */
.market-feed-card {
  display: flex;
  flex-direction: column;
  background: #1e1e1e;
  border-radius: 12px;
  padding: 12px;
  border: 1px solid #333;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.market-feed-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  border-color: #4b9cd3;
}

.feed-card-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.feed-card-title {
  font-weight: 600;
  font-size: 1rem;
  color: #fff;
}

.feed-card-metric {
  font-size: 0.9rem;
  font-weight: 700;
}

.feed-card-metric.positive {
  color: #4cd964;
}

.feed-sparkline {
  height: 50px;
  width: 100%;
}

/* ---------------------------------------------------
   HOT MARKETS TABLE (NEW)
--------------------------------------------------- */
.hot-markets-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 10px;
    font-size: 0.95rem;
    min-width: 300px;
}

.hot-markets-table th {
    text-align: right;
    padding: 12px 16px;
    color: #8892b0;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
    border-bottom: 1px solid #2c3e50;
    white-space: nowrap;
}

.hot-markets-table th.col-market {
    text-align: left;
}

/* Long parenthetical labels: default 1px letter-spacing reads too airy */
.hot-markets-table th.col-price,
.hot-markets-table th.col-change-1m,
.hot-markets-table th.col-sellthrough,
.hot-markets-table th.col-volume {
    letter-spacing: 0.04em;
    padding-left: 10px;
    padding-right: 10px;
}

.hot-markets-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.hot-markets-table th.sortable:hover {
    color: #a8b2d1;
}

.hot-markets-table th .hot-sort-ind {
    font-size: 0.65rem;
    opacity: 0.9;
    margin-left: 0.25em;
    white-space: nowrap;
}

.hot-markets-table td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid #1e2530;
    color: #e6f1ff;
}

.hot-markets-table td.col-price,
.hot-markets-table td.col-change-1m,
.hot-markets-table td.col-sellthrough,
.hot-markets-table td.col-volume {
    padding-left: 10px;
    padding-right: 10px;
}

.hot-markets-table tr.market-row {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.hot-markets-table tr.market-row:hover {
    background-color: #1e2530;
}

/* ---------------------------------------------------
   CUSTOM DROPDOWN (MATCHING TRENDS)
--------------------------------------------------- */
.custom-dropdown-container {
    position: relative;
    width: 100%;
    min-width: 140px;
}

.custom-dropdown-btn {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 24px 6px 10px; /* Right padding for arrow */
    background-color: var(--theme-bg-hobby-select);
    color: var(--theme-text-hobby-select);
    border: 1px solid var(--theme-border-hobby-select);
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 32px;
    line-height: 1.2;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.custom-dropdown-btn:hover {
    background-color: var(--theme-bg-hobby-select-hover);
    border-color: var(--theme-border-hobby-select-hover);
}

.custom-dropdown-btn:focus {
     box-shadow: var(--theme-analysis-dropdown-focus-ring);
     outline: none;
}

.custom-dropdown-btn::after {
    content: '';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234b9cd3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-size: contain;
    pointer-events: none;
    transition: transform 0.2s ease;
}

.custom-dropdown-container.active .custom-dropdown-btn::after {
    transform: translateY(-50%) rotate(180deg);
}

.custom-dropdown-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 220px; /* Wider than button if needed */
    max-height: 300px;
    overflow-y: auto;
    background-color: var(--theme-bg-dropdown);
    border: 1px solid var(--theme-border-default);
    border-radius: 6px;
    z-index: 10001; /* Ensure above bottom bar and table headers */
    box-shadow: var(--theme-shadow-dropdown);
    
    /* Animation */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.custom-dropdown-list.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-dropdown-header {
    padding: 8px 12px;
    background-color: var(--theme-panel-header-bg);
    color: var(--theme-text-heading);
    font-weight: bold;
    cursor: pointer;
    border-bottom: 1px solid var(--theme-border-default);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.custom-dropdown-header:hover {
    background-color: var(--theme-bg-glass-strong);
}

.custom-dropdown-header .toggle-icon {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    color: var(--theme-accent-primary);
}

.custom-dropdown-header.expanded .toggle-icon {
    transform: rotate(180deg);
}

.custom-dropdown-item {
    padding: 8px 12px 8px 20px;
    cursor: pointer;
    color: var(--theme-text-dropdown);
    border-bottom: 1px solid var(--theme-border-muted);
    background-color: var(--theme-bg-dropdown);
    font-size: 0.8rem;
    transition: background-color 0.2s, color 0.2s;
    
    /* Super category item logic */
    display: none; 
}

.custom-dropdown-item.always-visible {
    display: block;
}

.custom-dropdown-item:hover {
    background-color: var(--theme-bg-search-result-hover);
    color: var(--theme-text-dropdown);
}

.custom-dropdown-item.visible {
    display: block;
    animation: fadeIn 0.2s ease;
}

.custom-dropdown-item.selected {
    background-color: var(--theme-accent-a12);
    color: var(--theme-accent-primary);
    font-weight: 600;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}


/* Ensure dropdown appears above table rows */
.hot-markets-table thead th {
    position: relative;
    z-index: 10;
}

/* Scrollbar for dropdown */
.custom-dropdown-list::-webkit-scrollbar {
    width: 6px;
}
.custom-dropdown-list::-webkit-scrollbar-track {
    background: var(--theme-scrollbar-track);
    border-radius: 3px;
}
.custom-dropdown-list::-webkit-scrollbar-thumb {
    background: var(--theme-scrollbar-thumb);
    border-radius: 3px;
    border: 1px solid var(--theme-scrollbar-thumb-border);
}
.custom-dropdown-list::-webkit-scrollbar-thumb:hover {
    background: var(--theme-scrollbar-thumb-hover);
}

.col-market {
    width: 32%;
}

.market-name {
    font-weight: 600;
    color: #fff;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Monospace for numeric cells only — header matches other column titles (sans-serif). */
.hot-markets-table td.col-price {
    font-family: "Roboto Mono", monospace;
}

.col-price {
    text-align: right;
    width: 11%;
    color: #ccd6f6;
}

.col-change-1m {
    text-align: right;
    width: 11%;
    font-weight: 600;
}

.col-change-1m.positive {
    color: #4cd964;
}

.col-change-1m.negative {
    color: #ff3b30;
}

.col-sellthrough {
    text-align: right;
    width: 11%;
    color: #8892b0;
}

.col-volume {
    text-align: right;
    width: 12%;
    color: #a8b2d1;
}

.col-trend {
    width: 23%;
    text-align: right;
    padding-right: 0 !important;
}

.table-sparkline-container {
    width: 120px;
    height: 35px;
    display: inline-block;
    vertical-align: middle;
    margin-left: auto;
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .hot-markets-table th {
        padding: 8px 6px;
        font-size: 0.7rem;
    }
    
    .hot-markets-table td {
        padding: 8px 6px;
        font-size: 0.8rem;
    }

    .hot-markets-table th.col-price,
    .hot-markets-table th.col-change-1m,
    .hot-markets-table th.col-sellthrough,
    .hot-markets-table th.col-volume {
        padding-left: 6px;
        padding-right: 6px;
    }

    .hot-markets-table td.col-price,
    .hot-markets-table td.col-change-1m,
    .hot-markets-table td.col-sellthrough,
    .hot-markets-table td.col-volume {
        padding: 8px 6px;
    }

    .col-market {
        width: 40%;
    }
    
    .market-name {
        max-width: 100%;
    }
    
    .col-price {
        width: 15%;
    }
    
    .col-change-1m {
        width: 15%;
    }

    /* Hide Volume and Sellthrough on mobile to fit Sparkline */
    .col-volume, .col-sellthrough {
        display: none;
    }
    
    .hot-markets-table th.col-volume, 
    .hot-markets-table th.col-sellthrough {
        display: none;
    }
    
    .col-trend {
        width: 30%;
    }
    
    .table-sparkline-container {
        width: 70px;
        height: 30px;
    }
}

.trend-header {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  position: relative;
}

.trend-header h2 {
  flex-grow: 1;
  text-align: center; /* Ensures the text is centered relative to the available space */
  margin: 0;
}

.trend-header-home {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  position: relative;
  flex-wrap: wrap;
  gap: 10px;
  border-bottom: 3px solid var(--carolina-blue);
  padding-bottom: 8px;
}

.trend-header-home h2 {
  margin: 0;
  width: auto;
  border-bottom: none; /* Remove border from H2 as we applied it to container */
  padding-bottom: 0;
  font-size: 1.8rem;
}

#homeHotMarketsFilterContainer {
    width: 220px; 
    z-index: 100;
}

@media (max-width: 600px) {
    .trend-header-home {
        flex-direction: column;
        align-items: flex-start;
    }
    
    #homeHotMarketsFilterContainer {
        width: 100% !important;
    }

    #homePinnedMetricSelectorContainer {
        width: 100%;
    }

    .custom-dropdown-container {
        width: 100%;
    }
}

/* Empty State Message */
.empty-pins-message {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--theme-text-empty-pins);
    padding: 20px;
}

.pin-link {
    cursor: pointer;
    color: var(--theme-text-pin-link);
    font-weight: 500;
    transition: all 0.2s;
}

.pin-link:hover {
    color: var(--theme-text-pin-link-hover);
    text-decoration: underline;
}
