/* SentimentWidget — US-33 dashboard (dark theme) */

.sw-root {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 12px;
    color: #c9d1d9;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.sw-root * { box-sizing: border-box; }

/* Ensure the admin content area can scroll vertically when the dashboard is tall.
   The .admin-content parent already has overflow:auto but we make it explicit
   for cases where the widget is hosted outside the admin shell. */
.sw-root canvas {
    max-width: 100%;
    min-width: 0;
}

.sw-filterbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #161b22;
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 10px;
}

.sw-filterbar label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: #8b949e;
}

.sw-filterbar select,
.sw-filterbar input {
    background: #0d1117;
    border: 1px solid rgba(255,255,255,0.08);
    color: #c9d1d9;
    padding: 5px 8px;
    border-radius: 6px;
    font-size: 0.82rem;
    min-width: 140px;
}

.sw-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    color: #c9d1d9;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.82rem;
    transition: background 120ms, border-color 120ms;
}

.sw-btn:hover {
    background: rgba(99,102,241,0.1);
    border-color: rgba(99,102,241,0.35);
}

.sw-btn-primary {
    background: #6366f1;
    color: #fff;
    border-color: #6366f1;
}

.sw-btn-primary:hover {
    background: #5558e8;
}

.sw-btn i {
    margin-right: 4px;
}

.sw-status {
    font-size: 0.78rem;
    color: #8b949e;
    margin-left: auto;
}

.sw-status-ok { color: #4ade80; }
.sw-status-err { color: #f87171; }
.sw-status-warn { color: #fbbf24; }


.sw-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 900px) {
    .sw-charts { grid-template-columns: 1fr; }
}

.sw-card {
    background: #161b22;
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 10px;
    padding: 14px;
}

.sw-card h4 {
    margin: 0 0 10px;
    font-size: 0.88rem;
    font-weight: 600;
    color: #c9d1d9;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sw-hint {
    font-size: 0.72rem;
    color: #6e7681;
    font-weight: 400;
}

.sw-card-bar canvas,
.sw-card-pie canvas {
    max-height: 280px;
}

/* Bar chart card: fixed height so data-label plugin renders cleanly */
.sw-card-bar { display: flex; flex-direction: column; }
.sw-card-bar canvas {
    height: 260px !important;
    width: 100% !important;
    flex: 1 1 auto;
}

/* Trend chart (stacked bars): give the canvas room for the plugin labels on top */
.sw-chart-trend {
    height: 340px !important;
    width: 100% !important;
    max-height: 340px;
}

.sw-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.sw-table th,
.sw-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    vertical-align: top;
}

.sw-table th {
    font-weight: 600;
    color: #8b949e;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: rgba(255,255,255,0.02);
    position: sticky;
    top: 0;
    z-index: 1;
}

/* Zebra stripes — subtle on dark theme */
.sw-table tbody tr:nth-child(even) td {
    background: rgba(255,255,255,0.015);
}

.sw-table tr:hover td {
    background: rgba(99,102,241,0.06) !important;
}

.sw-topic-cell {
    font-weight: 600;
    color: #e6edf3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.sw-corp-pill {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(99,102,241,0.12);
    color: #a5b4fc;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.sw-motivation,
.sw-question {
    max-width: 380px;
    line-height: 1.4;
    color: #c9d1d9;
}

.sw-negative-wrap {
    max-height: 440px;
    overflow-y: auto;
}

.sw-empty {
    text-align: center !important;
    color: #6e7681;
    padding: 24px !important;
}

.sw-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
}

/* Ordered list of user questions inside a results row */
.sw-qlist {
    margin: 0;
    padding-left: 18px;
    list-style: decimal;
    color: #c9d1d9;
    font-size: 0.78rem;
    line-height: 1.4;
    max-height: 160px;
    overflow-y: auto;
}

.sw-qlist li {
    margin-bottom: 4px;
    padding-left: 2px;
}

.sw-qlist li::marker {
    color: #6e7681;
    font-size: 0.7rem;
}

.sw-motiv {
    color: #c9d1d9;
    font-size: 0.78rem;
    line-height: 1.4;
    margin-bottom: 6px;
}

.sw-unans {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: rgba(234,179,8,0.14);
    color: #fde68a;
    border: 1px solid rgba(234,179,8,0.35);
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.3;
    flex-wrap: wrap;
}

.sw-unans-summary {
    font-weight: 400;
    color: #e6edf3;
    font-size: 0.7rem;
    margin-left: 4px;
}

.sw-empty-cell {
    color: #6e7681;
}

/* Cluster questions panel: state chips */
.sw-unans-chip,
.sw-ok-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

.sw-unans-chip {
    background: rgba(234,179,8,0.14);
    color: #fde68a;
    border: 1px solid rgba(234,179,8,0.35);
}

.sw-ok-chip {
    background: rgba(16,185,129,0.14);
    color: #6ee7b7;
    border: 1px solid rgba(16,185,129,0.35);
}

/* "Non risposte" filter chip — yellow accent when active */
.sw-chip-unanswered.sw-chip-active {
    background: rgba(234,179,8,0.18);
    color: #fde68a;
    border-color: rgba(234,179,8,0.5);
}

/* Overview (cross-topic LLM brief) — THE landing card of the Analisi tab */
.sw-overview-card {
    border: 2px solid rgba(99,102,241,0.35);
    background: linear-gradient(135deg, rgba(99,102,241,0.06) 0%, #161b22 60%);
    padding: 18px 22px;
}

.sw-overview-card > h4 i {
    color: #a5b4fc;
}

.sw-overview-loader {
    padding: 28px 10px;
    text-align: center;
    color: #8b949e;
    font-size: 0.88rem;
}

.sw-overview-loader i {
    color: #a5b4fc;
    margin-right: 8px;
    font-size: 1rem;
}

.sw-overview-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Hero pie chart — big, centered, THE primary call-to-action */
.sw-pie-card {
    padding: 20px 22px;
}

.sw-pie-card h4 {
    justify-content: space-between;
}

.sw-pie-card canvas {
    height: 320px !important;
    max-height: 320px;
    width: 100% !important;
}

/* Advanced details (collapsed by default) — keeps the top-level page simple */
.sw-advanced {
    padding: 0;
}

.sw-advanced > summary {
    cursor: pointer;
    padding: 14px 18px;
    font-size: 0.88rem;
    font-weight: 600;
    color: #c9d1d9;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sw-advanced > summary::-webkit-details-marker { display: none; }
.sw-advanced > summary::marker { content: ""; }

.sw-advanced > summary::after {
    content: "▼";
    font-size: 0.7rem;
    color: #8b949e;
    margin-left: auto;
    transition: transform 180ms;
}

.sw-advanced[open] > summary::after { transform: rotate(180deg); }

.sw-advanced > summary:hover { color: #e6edf3; }

.sw-advanced-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 18px 18px;
}

.sw-advanced-body .sw-card {
    background: rgba(255,255,255,0.015);
}

/* ----- Cluster analysis panel (the main "comprehensive analysis" view) ----- */
.sw-cluster-panel {
    border: 2px solid rgba(99,102,241,0.35);
    background: linear-gradient(180deg, rgba(99,102,241,0.05) 0%, #161b22 60%);
    padding: 20px 22px;
}

.sw-cluster-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sw-cluster-head h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #e6edf3;
    flex: 1 1 auto;
    word-break: break-word;
}

.sw-cluster-name {
    color: #a5b4fc;
    text-transform: capitalize;
}

.sw-cluster-close {
    flex: 0 0 auto;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
    color: #8b949e;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    cursor: pointer;
}

.sw-cluster-close:hover {
    background: rgba(248,113,113,0.12);
    color: #f87171;
    border-color: rgba(248,113,113,0.35);
}

/* Stats strip above the analysis sections */
.sw-analysis-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
    padding: 12px 14px;
    background: rgba(255,255,255,0.02);
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.04);
}

.sw-analysis-stats > div {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.sw-analysis-stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: #e6edf3;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.sw-analysis-stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #8b949e;
}

.sw-analysis-loader {
    padding: 30px 10px;
    text-align: center;
    color: #8b949e;
    font-size: 0.88rem;
}

.sw-analysis-loader i {
    margin-right: 8px;
    color: #a5b4fc;
    font-size: 1rem;
}

.sw-analysis-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Sub-tabs inside the analysis card (Sintesi / Utenti / Problemi / Azioni) */
.sw-subtabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: 10px;
    margin-bottom: 12px;
}

.sw-subtab {
    flex: 1 1 auto;
    background: transparent;
    border: none;
    color: #8b949e;
    padding: 8px 14px;
    border-radius: 7px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 120ms, color 120ms;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

.sw-subtab i { font-size: 0.78rem; }

.sw-subtab:hover { color: #c9d1d9; background: rgba(255,255,255,0.04); }

.sw-subtab.active {
    background: rgba(99,102,241,0.2);
    color: #e6edf3;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.sw-subtab-panel { display: none; }
.sw-subtab-panel.active { display: block; animation: sw-fadein 160ms ease-out; }

@keyframes sw-fadein { from { opacity: 0; } to { opacity: 1; } }

.sw-sub-h {
    margin: 0 0 8px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #e6edf3;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sw-sub-h-muted {
    color: #8b949e;
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.04);
}

.sw-analysis-para {
    margin: 0 0 8px;
    font-size: 0.92rem;
    line-height: 1.6;
    color: #c9d1d9;
}

.sw-analysis-empty {
    margin: 0;
    font-size: 0.82rem;
    color: #6e7681;
    font-style: italic;
}

/* Analysis lists with icon bullet — more readable than plain <ul> */
.sw-analysis-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sw-analysis-list li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: 8px;
    font-size: 0.86rem;
    line-height: 1.45;
    color: #c9d1d9;
}

.sw-analysis-list li i {
    flex: 0 0 auto;
    font-size: 0.78rem;
    margin-top: 2px;
    color: #a5b4fc;
}

.sw-analysis-list li span { flex: 1 1 auto; min-width: 0; }

.sw-analysis-ok li { border-color: rgba(16,185,129,0.18); }
.sw-analysis-ok li i { color: #6ee7b7; }

.sw-analysis-warn li { border-color: rgba(234,179,8,0.18); }
.sw-analysis-warn li i { color: #fde68a; }

.sw-analysis-err li { border-color: rgba(239,68,68,0.18); }
.sw-analysis-err li i { color: #fca5a5; }

/* Back-compat — in case old markup lingers */
.sw-analysis-sec {
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(255,255,255,0.02);
    border-left: 3px solid rgba(99,102,241,0.5);
}

.sw-analysis-footer {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.04);
    font-size: 0.7rem;
    color: #6e7681;
    text-align: right;
    font-style: italic;
}

/* "Vedi tutte le domande" collapsed by default */
.sw-cluster-questions {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,0.04);
}

.sw-cluster-questions summary {
    cursor: pointer;
    font-size: 0.82rem;
    color: #8b949e;
    font-weight: 600;
    padding: 6px 0;
    user-select: none;
}

.sw-cluster-questions summary:hover { color: #c9d1d9; }

.sw-cluster-questions summary i { margin-right: 6px; color: #a5b4fc; }

.sw-cluster-questions[open] summary { color: #c9d1d9; margin-bottom: 8px; }

@media (max-width: 640px) {
    .sw-analysis-stats { grid-template-columns: repeat(2, 1fr); }
    .sw-analysis-stat-value { font-size: 1.15rem; }
}

/* Executive summary banner */
.sw-summary {
    display: grid;
    grid-template-columns: minmax(260px, 1.6fr) minmax(280px, 2fr);
    gap: 16px;
    padding: 18px 22px;
    background: linear-gradient(135deg, #161b22 0%, #1c2333 100%);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 14px;
    align-items: center;
}

.sw-summary-main {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.sw-summary-headline {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.sw-summary-score {
    font-size: 2.6rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
    color: #e6edf3;
    font-variant-numeric: tabular-nums;
}

.sw-summary-score.sw-score-good { color: #4ade80; }
.sw-summary-score.sw-score-warn { color: #fbbf24; }
.sw-summary-score.sw-score-bad { color: #f87171; }

.sw-summary-score-max {
    font-size: 1.1rem;
    color: #6e7681;
    font-weight: 500;
    margin-right: 6px;
}

.sw-summary-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #8b949e;
    font-weight: 600;
}

.sw-summary-sub {
    font-size: 0.82rem;
    color: #8b949e;
    line-height: 1.45;
}

.sw-summary-sub strong { color: #e6edf3; font-weight: 700; }

.sw-summary-secondary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding-left: 16px;
    border-left: 1px solid rgba(255,255,255,0.08);
}

.sw-metric {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sw-metric-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #e6edf3;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}

.sw-metric-neg .sw-metric-value { color: #f87171; }
.sw-metric-unans .sw-metric-value { color: #fbbf24; }

.sw-metric-label {
    font-size: 0.72rem;
    color: #8b949e;
    line-height: 1.3;
}

@media (max-width: 900px) {
    .sw-summary { grid-template-columns: 1fr; gap: 14px; padding: 16px; }
    .sw-summary-secondary { padding-left: 0; border-left: none; border-top: 1px solid rgba(255,255,255,0.08); padding-top: 14px; }
}

@media (max-width: 540px) {
    .sw-summary-secondary { grid-template-columns: repeat(3, 1fr); }
    .sw-metric-value { font-size: 1.25rem; }
    .sw-summary-score { font-size: 2.1rem; }
}

/* Decision-support insights panel — compact stat-first cards */
.sw-insights {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
}

.sw-insight {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 14px;
    background: #161b22;
    border: 1px solid rgba(255,255,255,0.05);
    border-left: 3px solid #6366f1;
    border-radius: 10px;
}

.sw-insight-ok { border-left-color: #10b981; }
.sw-insight-warn { border-left-color: #eab308; }
.sw-insight-err { border-left-color: #ef4444; }
.sw-insight-info { border-left-color: #6366f1; }

.sw-insight-icon {
    font-size: 1.1rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    flex: 0 0 auto;
    background: rgba(255,255,255,0.04);
}

.sw-insight-ok .sw-insight-icon { color: #4ade80; background: rgba(16,185,129,0.12); }
.sw-insight-warn .sw-insight-icon { color: #fbbf24; background: rgba(234,179,8,0.12); }
.sw-insight-err .sw-insight-icon { color: #f87171; background: rgba(239,68,68,0.12); }
.sw-insight-info .sw-insight-icon { color: #a5b4fc; background: rgba(99,102,241,0.12); }

.sw-insight-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sw-insight-stat {
    font-size: 1.25rem;
    font-weight: 700;
    color: #e6edf3;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.sw-insight-ok .sw-insight-stat { color: #4ade80; }
.sw-insight-warn .sw-insight-stat { color: #fbbf24; }
.sw-insight-err .sw-insight-stat { color: #f87171; }

.sw-insight-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #c9d1d9;
    line-height: 1.3;
}

.sw-insight-action {
    font-size: 0.72rem;
    color: #8b949e;
    line-height: 1.4;
    margin-top: 2px;
}

/* Tabs inside the widget */
.sw-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    padding: 0 4px;
}

.sw-tab {
    background: transparent;
    border: none;
    color: #8b949e;
    padding: 10px 16px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 120ms, border-color 120ms;
}

.sw-tab:hover { color: #c9d1d9; }

.sw-tab i { margin-right: 6px; font-size: 0.75rem; }

.sw-tab.active {
    color: #a5b4fc;
    border-bottom-color: #6366f1;
}

.sw-tab-panel { display: none; }
.sw-tab-panel.active { display: block; }

/* Topic × sentiment matrix (heatmap) */
.sw-matrix-wrap {
    overflow-x: auto;
}

.sw-matrix {
    min-width: 600px;
}

.sw-matrix th {
    text-align: center;
}

.sw-matrix .sw-mx-key {
    text-align: left;
    font-weight: 600;
    color: #e6edf3;
    max-width: 240px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sw-mx-score {
    font-weight: 700;
}

.sw-mx-cell,
.sw-mx-total,
.sw-mx-avg {
    text-align: center;
    font-variant-numeric: tabular-nums;
    min-width: 50px;
}

.sw-mx-total {
    font-weight: 600;
    color: #e6edf3;
}

.sw-mx-avg {
    color: #a5b4fc;
}

/* Paginated results table */
.sw-results-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.sw-results-head h4 { margin: 0; }

.sw-results-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.sw-score-filter {
    display: flex;
    gap: 4px;
}

.sw-chip {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
    color: #8b949e;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 120ms, color 120ms, border-color 120ms;
}

.sw-chip:hover {
    color: #c9d1d9;
    border-color: rgba(255,255,255,0.2);
}

.sw-chip-active {
    background: rgba(99,102,241,0.18);
    color: #a5b4fc;
    border-color: rgba(99,102,241,0.5);
}

.sw-results-wrap {
    max-height: 480px;
    overflow-y: auto;
}

.sw-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 12px;
    padding: 6px 0;
}

.sw-page-info {
    font-size: 0.82rem;
    color: #8b949e;
    font-variant-numeric: tabular-nums;
}

.sw-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.sw-btn:disabled:hover {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.08);
}

/* Custom scrollbar — visible indigo, matches admin board */
.sw-results-wrap,
.sw-negative-wrap,
.sw-matrix-wrap {
    scrollbar-width: thin;
    scrollbar-color: #6366f1 #161b22;
}

.sw-root ::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.sw-root ::-webkit-scrollbar-track {
    background: #161b22;
    border: 1px solid rgba(255,255,255,0.06);
}

.sw-root ::-webkit-scrollbar-thumb {
    background: #6366f1;
    border-radius: 6px;
}

.sw-root ::-webkit-scrollbar-thumb:hover {
    background: #818cf8;
}

.sw-root ::-webkit-scrollbar-thumb:active {
    background: #4f46e5;
}

/* Responsive: tablet and narrower */
@media (max-width: 1024px) {
    .sw-charts { grid-template-columns: 1fr; }
    .sw-matrix { min-width: 520px; }
    .sw-results-wrap,
    .sw-negative-wrap {
        max-height: 400px;
    }
}

@media (max-width: 768px) {
    .sw-root {
        padding: 8px;
        gap: 12px;
    }
    .sw-filterbar {
        gap: 8px;
        padding: 8px;
    }
    .sw-filterbar label,
    .sw-filterbar select,
    .sw-filterbar input {
        font-size: 0.76rem;
        min-width: 0;
    }
    .sw-filterbar label { flex: 1 1 140px; }
    .sw-filterbar input,
    .sw-filterbar select { min-width: 0; width: 100%; }
    .sw-btn { padding: 6px 10px; font-size: 0.76rem; }
    .sw-status { margin-left: 0; flex: 1 1 100%; }

    .sw-kpis { grid-template-columns: repeat(2, 1fr); }
    .sw-kpi-value { font-size: 1.35rem; }

    .sw-insights { grid-template-columns: 1fr; }

    .sw-tabs {
        overflow-x: auto;
        white-space: nowrap;
        flex-wrap: nowrap;
    }
    .sw-tab { flex: 0 0 auto; padding: 8px 12px; font-size: 0.76rem; }
    .sw-tab i { margin-right: 4px; }

    .sw-card { padding: 10px; }
    .sw-card h4 { font-size: 0.8rem; flex-wrap: wrap; }
    .sw-hint { font-size: 0.68rem; }

    .sw-chart-trend,
    .sw-chart-bytopic {
        max-height: 340px;
    }

    .sw-results-head {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .sw-results-controls { gap: 8px; }
    .sw-score-filter { flex-wrap: wrap; }

    .sw-table {
        font-size: 0.76rem;
    }
    .sw-table th,
    .sw-table td {
        padding: 6px 8px;
    }
    .sw-motivation,
    .sw-question {
        max-width: 220px;
    }
    .sw-pagination {
        flex-wrap: wrap;
        gap: 8px;
    }
    .sw-page-info { flex: 1 1 100%; text-align: center; }
}

@media (max-width: 480px) {
    .sw-kpis { grid-template-columns: 1fr; }
    .sw-chip { padding: 3px 8px; font-size: 0.7rem; }
}
