/* css/analysis.css */

/* HEADER MAKEOVER */
#marketanalysis .market-header h2 {
  text-align: left;
  font-size: 1.8rem;
  font-weight: 900;
  margin-top: 0;
  margin-bottom: 24px;
  color: var(--theme-explore-header-text);
  text-transform: uppercase;
  letter-spacing: 2.5px;
  text-shadow: var(--theme-explore-header-shadow);
  position: relative;
  display: block;
  width: 100%;
  padding-bottom: 12px;
  border-bottom: 4px solid var(--theme-accent-primary);
}

#marketanalysis .market-header {
    text-align: left;
}

#marketanalysis h3 {
    text-align: left;
    font-size: 1.8rem;
    font-weight: 800;
    margin-top: 20px;
    margin-bottom: 15px;
    color: var(--theme-explore-header-text);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    text-shadow: var(--theme-market-analysis-h3-shadow);
    position: relative;
    display: block;
    width: 100%;
    border-bottom: 2px solid var(--theme-accent-primary);
    padding-bottom: 5px;
    left: 0;
    transform: none;
}

/* Fix for Chart Title to match Trends tab */
#marketanalysis .chart-metric-title {
    text-align: center;
    border-bottom: none;
    padding-bottom: 0;
    margin-top: 5px;
    margin-bottom: 10px;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
    text-shadow: none;
    width: auto;
    display: block;
    color: var(--theme-market-chart-metric-title);
    font-weight: 600;
    text-transform: uppercase;
}

/* Compare chart: on narrow screens `.trends-chart-controls` stacks (trends.css) and the toolbar
   becomes tall. A fixed-height flex column was starving the canvas (only flex child with min-height:0).
   The plot shell owns a minimum height so the line chart never pancakes. */
#marketanalysis #analysisContent .chart-container {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
    height: auto;
    min-height: 0;
    max-height: none;
    flex-shrink: 0;
}

#marketanalysis #analysisContent .chart-container > .chart-metric-title,
#marketanalysis #analysisContent .chart-container > .trends-chart-header {
    flex-shrink: 0;
}

#marketanalysis #analysisContent .analysis-chart-plot-shell {
    width: 100%;
    min-height: 300px;
    height: clamp(300px, 48vh, 520px);
    flex: 0 0 auto;
    position: relative;
}

#marketanalysis #analysisChart {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    vertical-align: top;
}

/* Phones: vh fallback, then dvh when supported (mobile URL chrome) */
@media (max-width: 768px) {
    #marketanalysis #analysisContent .analysis-chart-plot-shell {
        min-height: 280px;
        height: clamp(280px, 40vh, 460px);
        height: clamp(280px, 40dvh, 460px);
    }
}

@media (max-width: 480px) {
    #marketanalysis #analysisContent .analysis-chart-plot-shell {
        min-height: 260px;
        height: clamp(260px, 36vh, 420px);
        height: clamp(260px, 36dvh, 420px);
    }
}

/* Selector Pair Grouping */
.selector-pair {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    min-width: 200px;
    background: var(--theme-selector-pair-bg);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--theme-selector-pair-border);
}

/* Override alignment for Analysis Selectors */
#marketanalysis .analysis-selectors {
    align-items: stretch;
}

/* Tab cards use overflow:hidden in components.css for rounded corners; that clips
   .custom-dropdown-list (position:absolute under .custom-dropdown-container). */
#marketanalysis section.dashboard-section {
    overflow: visible;
}

.analysis-btn-group {
    display: flex;
    gap: 10px;
    /* Make buttons stack vertically if needed, or side-by-side filling height */
    flex-direction: column; 
    justify-content: stretch;
}

.analysis-btn-group .action-btn {
    height: auto; /* Override fixed height */
    flex: 1;      /* Fill available vertical space */
    display: flex;
    align-items: center;
    justify-content: center;
}

.analysis-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    width: 100%;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--theme-analysis-actions-border);
}

@media (max-width: 768px) {
    .analysis-actions {
        flex-direction: column-reverse;
    }
    .analysis-actions .action-btn {
        width: 100%;
    }
}

.selector-group {
    width: 100%;
}

.selector-group .custom-dropdown-list {
    width: 100% !important;
    max-width: none;
}

/* Fix width for Custom Dropdown in Analysis Tab */
#marketanalysis .custom-dropdown-container {
    width: 100%;
    display: block;
}

#marketanalysis .custom-dropdown-btn {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Market Analysis only: Overview hobby rows at top of each super-category (see analysis.js sort + class) */
#marketanalysis .custom-dropdown-list .custom-dropdown-item.analysis-market-item--overview {
    font-weight: 700;
    border-left: 3px solid var(--theme-accent-primary);
    margin-left: 4px;
    padding-left: 9px;
    box-sizing: border-box;
    background: var(--theme-analysis-overview-item-bg, rgba(75, 156, 211, 0.14));
}

#marketanalysis .custom-dropdown-list .custom-dropdown-item.analysis-market-item--overview:hover {
    background: var(--theme-analysis-overview-item-hover-bg, rgba(75, 156, 211, 0.22));
}

/* Native sub-market selects: Overview optgroup + Sub-markets (styling varies by OS; label + weight help) */
#marketanalysis select.analysis-submarket-select optgroup.analysis-submarket-optgroup--overview {
    font-weight: 800;
    font-style: normal;
    color: var(--theme-accent-primary);
}

#marketanalysis select.analysis-submarket-select optgroup.analysis-submarket-optgroup:not(.analysis-submarket-optgroup--overview) {
    font-weight: 600;
    color: var(--theme-coll-browse-lead, #aaa);
}

/* Style Subcategory Selector to match Custom Dropdown */
.analysis-dropdown {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 10px;
    background-color: var(--theme-analysis-dropdown-bg);
    color: var(--theme-analysis-dropdown-text);
    border: 1px solid var(--theme-analysis-dropdown-border);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 400;
    font-family: inherit;
    cursor: pointer;
    height: 32px;
    line-height: 1.2;
    transition: all 0.2s ease;
    appearance: none; /* Remove default arrow to style consistently if needed, or keep for native feel */
    background-image: var(--theme-analysis-dropdown-chevron-img);
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 30px; /* Space for arrow */
}

.analysis-dropdown:hover {
    background-color: var(--theme-analysis-dropdown-hover-bg);
    border-color: var(--theme-analysis-dropdown-hover-border);
    box-shadow: var(--theme-analysis-dropdown-hover-shadow);
}

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

.analysis-dropdown:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    border-color: var(--theme-analysis-dropdown-disabled-border);
}

/* Product Analysis: product picker with collapsible year groups (native select kept for state / programmatic select) */
.explore-product-combobox {
    position: relative;
    width: 100%;
    z-index: 1;
}

.explore-product-combobox:has(.explore-product-combobox__panel:not([hidden])) {
    z-index: 800;
}

button.explore-product-combobox__btn.analysis-dropdown {
    text-align: left;
}

.explore-product-combobox__label {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.explore-product-combobox__native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    clip-path: inset(50%) !important;
}

.explore-product-combobox__panel {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 900;
    margin-top: 4px;
    max-height: min(60vh, 420px);
    overflow-y: auto;
    overflow-x: hidden;
    background-color: var(--theme-analysis-dropdown-bg);
    color: var(--theme-analysis-dropdown-text);
    border: 1px solid var(--theme-analysis-dropdown-border);
    border-radius: 6px;
    box-shadow: var(--theme-analysis-dropdown-hover-shadow);
    padding: 4px 0;
}

.explore-product-year-group {
    border-bottom: 1px solid var(--theme-analysis-dropdown-border);
}

.explore-product-year-group:last-child {
    border-bottom: none;
}

.explore-product-year-group > summary {
    cursor: pointer;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    list-style: none;
    user-select: none;
}

.explore-product-year-group > summary::-webkit-details-marker {
    display: none;
}

.explore-product-year-group > summary::before {
    content: "▸";
    display: inline-block;
    width: 0.9em;
    margin-right: 0.35em;
    font-size: 0.75em;
    opacity: 0.85;
    transition: transform 0.15s ease;
}

.explore-product-year-group[open] > summary::before {
    transform: rotate(90deg);
}

.explore-product-year-group__list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 2px 8px 10px 14px;
}

.explore-product-option {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
    padding: 6px 8px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.82rem;
    line-height: 1.25;
    cursor: pointer;
}

.explore-product-option:hover {
    background-color: var(--theme-analysis-dropdown-hover-bg);
}

/* Metric Dropdown */
.metric-dropdown {
    background: var(--theme-analysis-metric-bg);
    color: var(--theme-analysis-metric-text);
    border: 1px solid var(--theme-analysis-metric-border);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Insights */
.insights-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.insight-card {
    flex: 1;
    min-width: 300px;
    background: var(--theme-insight-card-bg);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--theme-tab-surface-border);
    border-top: 4px solid var(--theme-analysis-series-a);
    box-shadow: var(--theme-tab-surface-shadow);
}

.insight-card.insight-card--series-a {
    border-top-color: var(--theme-analysis-series-a);
}

.insight-card.insight-card--series-b {
    border-top-color: var(--theme-analysis-series-b);
}

.insight-card h4 {
    margin-top: 0;
    color: var(--theme-insight-card-title);
    font-size: 1.1rem;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--theme-insight-card-title-border);
    padding-bottom: 10px;
}

/* Label left, status centered in the full bar, % right — not flex space-between (that pulls the label off-center). */
.signal-box {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid transparent;
}

.signal-box.positive { 
    background: var(--theme-signal-positive-bg);
    border-color: var(--theme-signal-positive-border);
}

.signal-box.negative { 
    background: var(--theme-signal-negative-bg);
    border-color: var(--theme-signal-negative-border);
}

.signal-box.neutral { 
    background: var(--theme-signal-neutral-bg);
    border-color: var(--theme-signal-neutral-border);
}

.signal-label {
    font-size: 0.8rem;
    color: var(--theme-roi-label);
    text-transform: uppercase;
    justify-self: start;
    text-align: left;
}
.signal-value {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--theme-roi-value);
    justify-self: center;
    text-align: center;
}
.signal-detail {
    font-size: 0.9rem;
    color: var(--theme-signal-detail);
    justify-self: end;
    text-align: right;
    white-space: nowrap;
}

.subfilter-analysis {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sub-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    border-radius: 6px;
    background: var(--theme-sub-stat-bg);
}

.sub-stat-hot { border: 1px solid var(--theme-sub-stat-hot-border); }
.sub-stat-cold { border: 1px solid var(--theme-sub-stat-cold-border); }

.sub-stat--clickable {
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.sub-stat--clickable:hover {
    transform: translateY(-1px);
    box-shadow: var(--theme-shadow-card-hover);
}

.sub-stat-icon { font-size: 1.2rem; margin-right: 10px; }
.sub-stat-info { flex: 1; min-width: 0; }
.sub-stat-name {
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--theme-roi-value);
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sub-stat-val { font-size: 0.8rem; color: var(--theme-roi-label); }

.sub-stat-path {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--theme-roi-value);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    max-width: 100%;
}

/* Stats Grid (legacy / other uses) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

#marketanalysis .stats-breakdown-grid {
    display: block;
    width: 100%;
}

.stat-box {
    background: var(--theme-stat-box-bg);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.stat-box h5 { margin: 0 0 5px 0; font-size: 0.8rem; color: var(--theme-roi-label); text-transform: uppercase; }
.stat-box p { margin: 0; font-size: 1.4rem; font-weight: bold; color: var(--theme-roi-value); }

/* Top active listings (Item Lookup) — Market Analysis */
.top-sales-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: min(640px, 70vh);
    overflow-y: auto;
}

.analysis-top-sales-cols {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px 20px;
    align-items: start;
}

.analysis-top-sales-col {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#marketanalysis .analysis-top-sales-col--series-a .analysis-top-sales-group {
    border-top: 4px solid var(--theme-analysis-series-a);
    padding-top: 10px;
}

#marketanalysis .analysis-top-sales-col--series-b .analysis-top-sales-group {
    border-top: 4px solid var(--theme-analysis-series-b);
    padding-top: 10px;
}

@media (max-width: 900px) {
    .analysis-top-sales-cols {
        grid-template-columns: 1fr;
    }
}

.analysis-top-sales-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.analysis-top-sales-market-title {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--theme-roi-label, #111827);
}

.analysis-top-sales-rows {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.analysis-top-sales-hint,
.analysis-top-sales-fallback {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.45;
    color: var(--theme-sales-date, #111827);
}

.analysis-top-sales-fallback {
    font-size: 0.78rem;
    opacity: 0.9;
}

.sales-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: var(--theme-sales-item-bg);
    border-radius: 6px;
    border-bottom: 1px solid var(--theme-sales-item-border);
}

.sales-item:hover {
    background: var(--theme-sales-item-hover-bg);
}

.sales-item--item-lookup {
    cursor: pointer;
    text-align: left;
}

.sales-item--item-lookup:focus {
    outline: 2px solid var(--theme-accent-primary, #38bdf8);
    outline-offset: 2px;
}

.sales-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
    padding-right: 10px;
}

.sales-title { font-size: 0.9rem; color: var(--theme-roi-value); font-weight: 500; }
.sales-date { font-size: 0.8rem; color: var(--theme-sales-date); }
.sales-meta {
    font-size: 0.78rem;
    color: var(--theme-sales-date);
    line-height: 1.35;
}
.sales-price { font-size: 1rem; font-weight: bold; color: var(--theme-sales-price); flex-shrink: 0; }
.sales-median-tag {
    display: inline-block;
    margin-left: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    vertical-align: middle;
    opacity: 0.85;
}

/* Custom Chart Legend */
.custom-chart-legend-container {
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
}

.custom-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.custom-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--theme-legend-item-text);
    background: var(--theme-legend-item-bg);
    padding: 4px 8px;
    border-radius: 4px;
    transition: opacity 0.2s;
}

.legend-color-box {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    display: inline-block;
}

.legend-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.legend-subcategory {
    font-size: 0.75rem;
    opacity: 0.7;
    text-transform: uppercase;
}

.legend-filter {
    font-weight: 600;
    color: var(--theme-roi-value);
}

/* Statistical Breakdown — Market Comparison (panel layout, compact) */
#marketanalysis .stats-breakdown-section {
    background: var(--theme-stats-breakdown-wrap-bg);
    border: 1px solid var(--theme-stats-breakdown-wrap-border);
    border-radius: var(--theme-tab-surface-radius, 12px);
    padding: 0.85rem 0.9rem 1rem;
    box-shadow: var(--theme-stats-column-shadow);
}

.stats-breakdown-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 0.75rem;
    flex-wrap: nowrap;
    width: 100%;
    box-sizing: border-box;
    padding-bottom: 0.4rem;
    margin-bottom: 0.65rem;
    border-bottom: 2px solid var(--theme-accent-primary);
}

@media (max-width: 480px) {
    .stats-breakdown-title-row {
        flex-wrap: wrap;
    }
}

/* Override global #marketanalysis h3 (full-width bar) for compact title + chart period row */
#marketanalysis .stats-breakdown-heading {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-top: 0;
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
    text-shadow: none;
    color: var(--theme-explore-header-text);
}

#marketanalysis .stats-breakdown-title-row .stats-breakdown-heading {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    max-width: 100%;
    display: block;
    line-height: 1.25;
}

.stats-breakdown-header-side {
    flex: 0 0 auto;
    margin-left: auto;
}

#marketanalysis .stats-breakdown-lead {
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--theme-stats-metric-label);
    margin: 0 0 1rem;
    max-width: 48rem;
}

.stats-breakdown-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin-bottom: 0;
    justify-content: flex-end;
}

.stats-breakdown-meta-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--theme-stats-metric-sub);
}

.stats-breakdown-range-pill {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
    background: var(--theme-stats-range-pill-bg);
    border: 1px solid var(--theme-stats-range-pill-border);
    color: var(--theme-stats-breakdown-range);
    line-height: 1.2;
}

.stats-breakdown-empty {
    text-align: center;
    padding: 2rem 1.25rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--theme-stats-metric-sub);
    border: 1px dashed var(--theme-stats-breakdown-wrap-border);
    border-radius: var(--theme-tab-surface-radius, 12px);
    background: var(--theme-stats-placeholder-bg);
}

/* Takeaways — summary under Statistical Breakdown */
.analysis-takeaways {
    margin-top: 1rem;
    padding: 0.85rem 1rem 1rem;
    border-radius: var(--theme-tab-surface-radius, 10px);
    border: 1px solid var(--theme-stats-breakdown-wrap-border);
    background: var(--theme-stats-placeholder-bg);
    box-sizing: border-box;
}

.analysis-takeaways-heading {
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin: 0 0 0.35rem;
    color: var(--theme-explore-header-text);
}

.analysis-takeaways-lead {
    font-size: 0.75rem;
    color: var(--theme-stats-metric-sub);
    margin: 0 0 0.4rem;
    line-height: 1.45;
}

.analysis-takeaways-disclaimer {
    font-size: 0.6875rem;
    line-height: 1.45;
    color: var(--theme-stats-metric-sub);
    margin: 0 0 0.75rem;
    opacity: 0.95;
}

.analysis-takeaways-disclaimer strong {
    color: var(--theme-stats-metric-label);
    font-weight: 600;
}

.analysis-takeaways-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.analysis-takeaways-item {
    display: flex;
    flex-direction: column;
    gap: 0.28rem;
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    background: var(--theme-insight-card-bg);
    border: 1px solid var(--theme-tab-surface-border);
    box-sizing: border-box;
}

.analysis-takeaways-pillar {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--theme-accent-primary);
}

.analysis-takeaways-text {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--theme-stats-metric-label);
}

.analysis-takeaways-text strong {
    color: var(--theme-roi-value);
    font-weight: 600;
}

.analysis-takeaways-item--health {
    border-color: var(--theme-accent-primary);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.analysis-takeaways-text--health-body {
    margin: 0;
}

.analysis-takeaways-health-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.analysis-takeaways-health-line {
    margin: 0;
    font-size: inherit;
    line-height: inherit;
}

/* Match chart series colors — only inside Market health takeaway when two markets */
.analysis-takeaways-market {
    font-weight: 700;
}

.analysis-takeaways-market--a {
    color: var(--theme-analysis-series-a);
}

.analysis-takeaways-market--b {
    color: var(--theme-analysis-series-b);
}

.stats-breakdown-container {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(180px, 0.92fr);
    gap: 0.65rem 0.65rem;
    align-items: stretch;
    width: 100%;
}

@media (max-width: 768px) {
    .stats-breakdown-container {
        grid-template-columns: 1fr;
    }
}

.stats-column {
    background: var(--theme-stats-column-bg);
    border-radius: var(--theme-tab-surface-radius, 12px);
    padding: 0;
    border: 1px solid var(--theme-stats-column-border);
    box-sizing: border-box;
    box-shadow: var(--theme-stats-column-shadow);
    overflow: hidden;
    min-width: 0;
}

.stats-column--a:not(.stats-column--placeholder) {
    border-top: 4px solid var(--theme-analysis-series-a);
}

.stats-column--b:not(.stats-column--placeholder) {
    border-top: 4px solid var(--theme-analysis-series-b);
}

.stats-column--summary {
    border-top: 3px solid var(--theme-stats-summary-accent);
    background: var(--theme-stats-summary-bg);
}

.stats-summary-placeholder {
    padding: 1rem 0.85rem;
    text-align: center;
    font-size: 0.75rem;
    line-height: 1.45;
    color: var(--theme-stats-metric-sub);
}

/* Comparison column: same flex row + value cell as market columns */
#marketanalysis .stats-column--summary .stats-metric-right {
    min-width: 0;
}

/* Comparison column: no green/red — same emphasis as primary metric text */
#marketanalysis .stats-column--summary .stats-metric-value,
#marketanalysis .stats-column--summary .stats-metric-value.summary-favors-m1,
#marketanalysis .stats-column--summary .stats-metric-value.summary-favors-m2,
#marketanalysis .stats-column--summary .stats-metric-value.summary-neutral {
    color: var(--theme-roi-value);
    font-weight: 600;
}

#marketanalysis .stats-column--summary .stats-metric-value {
    text-align: right;
    word-break: break-word;
    font-size: 0.75rem;
    line-height: 1.28;
}

/* Reserve same vertical space as H/L sub-line in market columns (avg / median rows) */
#marketanalysis .stats-column--summary .stats-metric-sub--spacer {
    color: transparent;
    user-select: none;
    pointer-events: none;
}

.stats-column--placeholder {
    border-top-color: transparent;
    background: var(--theme-stats-placeholder-bg);
    border-style: dashed;
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stats-column-placeholder-msg {
    text-align: center;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--theme-stats-metric-sub);
    padding: 1.25rem;
    max-width: 15rem;
}

.stats-market-title {
    margin: 0;
    padding: 0.55rem 0.65rem 0.5rem;
    border-bottom: 1px solid var(--theme-stats-section-border);
    text-align: left;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
}

.stats-market-slot {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--theme-stats-metric-sub);
}

.stats-market-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--theme-stats-market-title);
    line-height: 1.25;
    word-break: break-word;
}

.stats-category {
    margin: 0;
    padding: 0.45rem 0.55rem 0.35rem;
    border-bottom: 1px solid var(--theme-stats-section-border);
}

.stats-category:last-child {
    border-bottom: none;
    padding-bottom: 0.55rem;
}

.stats-category-title {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--theme-stats-category-accent);
    margin: 0 0 0.35rem;
    padding: 0.2rem 0 0.2rem 0.65rem;
    text-align: left;
    border-bottom: none;
    border-left: 3px solid var(--theme-stats-category-accent);
    line-height: 1.35;
}

.stats-metric-row {
    padding: 0.3rem 0.25rem;
    margin: 0 -0.1rem;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
    border-radius: 4px;
    border-bottom: 1px solid var(--theme-stats-metric-row-border);
    transition: background 0.15s ease;
}

/* Keep metric rows the same height across Market / Market / Comparison columns */
#marketanalysis .stats-breakdown-container .stats-metric-row {
    box-sizing: border-box;
    min-height: 3.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#marketanalysis .stats-breakdown-container .stats-metric-content {
    flex: 1 1 auto;
    align-items: center;
    min-height: 100%;
    gap: 0.45rem;
}

.stats-metric-row:hover {
    background: var(--theme-stats-metric-row-hover);
}

.stats-metric-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

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

.stats-metric-label {
    font-size: 0.75rem;
    color: var(--theme-stats-metric-label);
    font-weight: 500;
    line-height: 1.28;
    flex: 1 1 auto;
    min-width: 0;
}

.stats-metric-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex: 0 1 auto;
    text-align: right;
}

.stats-metric-value {
    font-size: 0.875rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--theme-roi-value);
    line-height: 1.2;
}

/* Trend Indicators - Scoped to Analysis Tab */
#marketanalysis .trend-indicator {
    font-size: 0.625rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    margin-left: 4px;
    padding: 0.1rem 0.32rem;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    vertical-align: middle;
}

#marketanalysis .trend-up {
    color: var(--theme-trend-up-text);
    background: var(--theme-trend-up-bg);
}

#marketanalysis .trend-down {
    color: var(--theme-trend-down-text);
    background: var(--theme-trend-down-bg);
}

#marketanalysis .trend-neutral {
    color: var(--theme-trend-neutral-text);
}

/* Comparison Highlighting - Scoped to Analysis Tab */
#marketanalysis .comp-win {
    color: var(--theme-trend-up-text) !important;
}

#marketanalysis .comp-loss {
    color: var(--theme-trend-down-text) !important;
}

#marketanalysis .comp-neutral {
    color: var(--theme-roi-value) !important;
    opacity: 0.85;
}

.stats-metric-sub {
    font-size: 0.625rem;
    color: var(--theme-stats-metric-sub);
    margin-top: 0.1rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
    line-height: 1.25;
}

#marketanalysis .stats-metric-row.has-sub .stats-metric-right > div:first-child {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: flex-end;
    gap: 0.15rem 0;
}



