/* Midnight dark purple scheme */
:root {
    --tblr-primary: #6c43a3;
    /* midnight purple */
    --tblr-success: #2e7d6a;
    /* muted teal for success accents */
    --tblr-danger: #cc3b3b;
    --tblr-warning: #d19a33;
    --tblr-body-bg: #0f0b16;
    --tblr-border-color: rgba(122, 134, 153, 0.18);
    --tblr-body-color: #e5e7eb;
}

body.light {
    --tblr-body-bg: var(--bg-0, #f8fafc);
    --tblr-body-color: var(--text, #1f2937);
}

/* Chart containers: fixed heights, no percentage heights */
.chart-container {
    height: 200px;
    display: block;
}

.chart-container.chart-sm {
    height: 56px;
}

.chart-container.chart-lg {
    height: 300px;
}

.btn-outline-success {
    color: var(--tblr-body-color);
    border-color: var(--tblr-primary);
}

.btn-outline-success:hover {
    color: #fff;
    background: var(--tblr-primary);
}

/* Industry toggle pressed styles */
#btnP50[aria-pressed="true"],
#btnP90[aria-pressed="true"] {
    color: #fff;
    background: var(--tblr-primary);
    border-color: var(--tblr-primary);
}

/* Card polish for dark */
.card {
    background: rgba(19, 16, 28, 0.92);
    border-color: var(--tblr-border-color);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.card:hover {
    transform: translateY(-2px);
}

.accordion-button {
    background: linear-gradient(135deg, #6c43a3, #4a2a7d);
    color: white;
}

.accordion-body {
    background: #13101c;
}

body.light .card {
    background: #ffffff;
}

/* Prevent horizontal overflow on small viewports */
.container-xl,
.page-wrapper,
.page-body {
    overflow-x: hidden;
}

.row-cards>.col,
.row-cards>[class^="col-"] {
    margin-bottom: 1rem;
}

/* Compact card variant to resemble Tabler preview tiles */
.card.card-sm .card-body {
    padding: .5rem .75rem;
}

.card .card-title {
    font-weight: 600;
    letter-spacing: 0.2px;
    font-size: 0.875rem;
}

/* Shrink card headers height globally */
.card .card-header {
    padding: 4px 8px;
}

.page .page-header {
    margin-bottom: 1rem;
}

.row-cards.g-2>[class^="col-"] {
    margin-bottom: .75rem;
}

/* Dashboard adapter for classes used by our handler */
.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 6px rgba(0, 0, 0, .25);
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #f8fafc;
}

.metric-label {
    font-size: .875rem;
    color: var(--tblr-muted, #94a3b8);
}

.speedometer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Reduce first-row visual footprint aggressively */
/* Ensure all top-row speedometers share the same height (match Market Fit) */
#overview-toprow .chart-container,
#market-fit-toprow .chart-container,
#reputation-toprow .chart-container,
#visibility-toprow .chart-container,
#performance-toprow .chart-container {
    height: 200px;
}

/* Radial score label size (allow chart options to override) */
.apexcharts-datalabels-group .apexcharts-datalabel-value {
    font-size: 50px;
    font-weight: 700;
    line-height: 1;
}

/* Compact KPI tiles in the first row */
#overview-kpi-card .card-body,
.kpi-card .card-body {
    padding: 6px 8px;
}

#overview-kpi .card.card-sm,
.kpi-tiles .card.card-sm {
    margin-bottom: 2px;
}

#overview-kpi .card.card-sm .card-body,
.kpi-tiles .card.card-sm .card-body {
    padding: 3px 6px;
}

#overview-kpi .card.card-sm .h3,
.kpi-tiles .card.card-sm .h3 {
    font-size: 1.05rem;
}

#overview-kpi .card.card-sm .text-muted,
.kpi-tiles .card.card-sm .text-muted {
    font-size: 11px;
}

#overview-kpi .gapbar,
.kpi-tiles .gapbar {
    height: 3px;
}

/* Zero gaps between KPI tiles */
#overview-kpi .row.row-cards.g-0>[class^="col-"],
.kpi-tiles.row.row-cards.g-0>[class^="col-"] {
    margin-bottom: 0;
}

/* Extra-tighten KPI tile spacing inside Overview 4 Pillars card */
#overview-kpi-card .kpi-tiles .card {
    margin-bottom: 0;
}

#overview-kpi-card .kpi-tiles .h3 {
    font-size: 1rem;
}

#overview-kpi-card .kpi-tiles .gapbar {
    height: 3px;
    margin-top: 2px;
}

#overview-kpi-card .row.row-cards>[class^="col-"] {
    margin-bottom: 2px;
}

/* Priority Spotlights: reduce card height footprint */
#benchmark-hub-snapshot.card .card-body {
    padding-top: 3px;
    padding-bottom: 3px;
}

#benchmark-hub-snapshot .list-group-item {
    padding: 3px 6px;
}

#benchmark-hub-snapshot .d-flex.justify-content-between {
    gap: 10px;
}

/* Markers for competitor lines on progress bars */
#benchmark-hub-snapshot .gapbar {
    position: relative;
}

#benchmark-hub-snapshot .gapbar .marker {
    position: absolute;
    top: -3px;
    width: 3px;
    height: 16px;
    background: var(--tblr-secondary, #a0aec0);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.06);
}

#benchmark-hub-snapshot .gapbar .marker.marker-top {
    background: var(--tblr-primary, #6c43a3);
}

#benchmark-hub-snapshot .gapbar .marker.marker-p90 {
    background: #57c3df;
}

/* Compact Top 3 Insights items */
/* Tighten Top Insights padding across all tabs (overview and others) */
#top-insights.list-group .list-group-item,
#top-insights-overview.list-group .list-group-item {
    padding: 5px 8px !important;
}

/* Top Insights: plain text first column with fixed width */
#top-insights .insight-col-label,
#top-insights-overview .insight-col-label {
    min-width: 140px;
    max-width: 140px;
    flex: 0 0 140px;
    font-weight: 600;
    text-transform: capitalize;
    color: var(--tblr-body-color);
}

#top-insights .insight-col-title,
#top-insights-overview .insight-col-title {
    color: var(--tblr-body-color);
}

/* Overview header cards follow Tabler rhythm, no scaling hacks */
#overview .row.row-cards>.col-lg-8 .card {
    min-height: 360px;
}

.heatmap-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: .75rem;
    font-weight: 600;
}

/* Gap bars used in spotlights */
.gapbar {
    width: 100%;
    height: 10px;
    background: rgba(100, 116, 139, 0.25);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.gapbar .fill {
    height: 100%;
    background: var(--tblr-primary);
    border-radius: 999px;
    transition: width .25s ease;
}

/* Compact horizontal bar for mentions count in reputation table */
.mentions-bar {
    width: 120px;
    height: 8px;
    background: rgba(100, 116, 139, 0.25);
    border-radius: 999px;
    overflow: hidden;
}

.mentions-bar .fill {
    height: 100%;
    background: var(--tblr-primary, #6c43a3);
    border-radius: 999px;
}

/* Compact mini bar used in pillar overview tables */
.mini-bar {
    width: 100%;
    height: 8px;
    background: rgba(100, 116, 139, 0.25);
    border-radius: 999px;
    overflow: hidden;
}

.mini-bar .fill {
    height: 100%;
    background: var(--tblr-primary, #6c43a3);
    border-radius: 999px;
}

/* Enforce design guardrails for ApexCharts */
.apexcharts-toolbar {
    display: none !important;
}

.apexcharts-canvas,
.apexcharts-svg {
    max-width: 100%;
}

/* Ensure chart SVG sits above card backgrounds */
.apexcharts-svg {
    position: relative;
    z-index: 1;
}

.apexcharts-annotations,
.apexcharts-series {
    position: relative;
    z-index: 2;
}

/* Diagnostics badges */
#diag-badges .badge {
    margin-right: 6px;
}

/* SVG sparkline fallback */
.sparkline {
    width: 100%;
    height: 56px;
    display: block;
}

/* Chart skeleton shimmer */
.skeleton {
    position: relative;
    overflow: hidden;
    background: linear-gradient(90deg, rgba(148, 163, 184, 0.08) 25%, rgba(148, 163, 184, 0.14) 37%, rgba(148, 163, 184, 0.08) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.2s ease-in-out infinite;
}

@keyframes shimmer {
    0% {
        background-position: 100% 0;
    }

    100% {
        background-position: 0 0;
    }
}

/* Card chart containers: prevent overflow and embed neatly */
.card .chart-container {
    width: 100%;
    height: 200px;
    display: block;
    overflow: hidden;
}

/* Reputation Sentiment chart sizing */
#rep-timeseries {
    width: 100%;
}

/* REP-10 chart: constrain to small strip above table (≈20% target) */
#rep-timeseries-card .chart-container {
    height: 96px;
    /* ~20% of a ~480px content area */
    overflow: hidden;
    /* keep chart within the container */
    margin-bottom: 6px;
}

/* Apply same containment to VIS-10 */
#vis-timeseries-card .chart-container {
    height: 96px;
    overflow: hidden;
    margin-bottom: 6px;
}

#vis-timeseries-card .apexcharts-canvas,
#vis-timeseries-card .apexcharts-svg,
#vis-timeseries-card .apexcharts-inner {
    height: 100% !important;
    max-height: 100% !important;
}

/* Ensure Apex SVG respects the container height within REP-10 */
#rep-timeseries-card .apexcharts-canvas,
#rep-timeseries-card .apexcharts-svg,
#rep-timeseries-card .apexcharts-inner {
    height: 100% !important;
    max-height: 100% !important;
}

/* A11y utility: visually hidden but accessible to screen readers */
.visually-hidden {
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
    border: 0;
    padding: 0;
    margin: -1px;
}

/* Defensive: avoid Apex chart from allocating extra inner height */
#rep-timeseries-card .apexcharts-xaxis,
#rep-timeseries-card .apexcharts-yaxis {
    transform: translateY(0) !important;
}

/* Heat level utilities for badges and list items */
.heat-high {
    background: rgba(108, 67, 163, 0.18);
    color: #caa8ff;
}

.heat-medium {
    background: rgba(108, 67, 163, 0.12);
    color: #b694ff;
}

.heat-low {
    background: rgba(108, 67, 163, 0.08);
    color: #a884ff;
}

.heat-critical {
    background: rgba(204, 59, 59, 0.18);
    color: #ff9a9a;
}

/* Evidence drawer (right-side panel) */
.evidence-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.7);
    z-index: 10000;
}

.evidence-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: min(720px, 96vw);
    background: rgba(15, 23, 42, 0.98);
    border-left: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    display: flex;
    flex-direction: column;
}

.evidence-drawer .drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--tblr-border-color);
}

.evidence-drawer .drawer-body {
    padding: 12px 16px;
    overflow: auto;
}

.evidence-tabs {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--tblr-border-color);
}

.evidence-tab {
    font-size: 12px;
    padding: 6px 10px;
    border: 1px solid rgba(147, 51, 234, 0.35);
    border-radius: 999px;
    cursor: pointer;
}

.evidence-tab[aria-selected="true"] {
    background: rgba(147, 51, 234, 0.18);
}

/* Floating action buttons stack (right) */
.fab-stack {
    right: 16px;
    bottom: 120px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
}

.fab-stack {
    display: none;
}

/* KPI vertical rows */
.kpi-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px 0;
}

.kpi-row .kpi-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--tblr-body-color);
}

.kpi-row .kpi-bar {
    height: 8px;
    background: rgba(100, 116, 139, 0.25);
    border-radius: 999px;
    overflow: hidden;
}

.kpi-row .kpi-bar .fill {
    height: 100%;
    background: var(--tblr-primary);
    width: 0;
    border-radius: 999px;
}

.kpi-row .kpi-meta {
    font-size: 12px;
    color: #94a3b8;
    display: flex;
    gap: 12px;
}

.equal-height-row {
    display: flex;
    flex-wrap: wrap;
}

.equal-height-row>[class*="col-"] {
    display: flex;
}

.equal-height-row .card {
    height: 100%;
    overflow: auto;
}

@media (max-width: 768px) {
    .equal-height-row {
        flex-direction: column;
    }

    .equal-height-row .card {
        height: auto;
        margin-bottom: 1rem;
    }
}

/* Utilities extracted from inline styles to reduce duplication */
.badge-row {
    margin-bottom: 0.5rem;
}

.mt-1 {
    margin-top: 0.25rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-3 {
    margin-top: 1rem;
}

.mb-1 {
    margin-bottom: 0.25rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

.text-12 {
    font-size: 12px;
}

.text-muted-2 {
    color: #94a3b8;
}

.progress-8 {
    height: 8px;
}

.progress-10 {
    height: 10px;
}