/* ══════════════════════════════════════════════════════
   v2-styles.css — Dashboard V2 Enhancements
   Imports base styles + adds 10 improvement styles
   ══════════════════════════════════════════════════════ */

@import url('/css/styles.css');

/* ─── 0. Global V2 overflow fix ──────────────────────── */
html { overflow-x: hidden; }
body { overflow-x: hidden; }

/* Header must sit above all chart cards so bell dropdown is visible */
.header { position: relative; z-index: 1000; }

/* ─── 1. Sparklines + Delta (hidden — cards show data only) ── */
.kpi-extra, .sparkline, .kpi-delta, .kpi-target { display: none; }

/* ─── 2. Skeleton Loading ────────────────────────────── */
.skeleton {
    position: absolute;
    inset: 0;
    z-index: 2;
    border-radius: var(--radius);
    background: linear-gradient(
        90deg,
        var(--bg-card) 25%,
        var(--bg-card-hover) 50%,
        var(--bg-card) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}
.skeleton-kpi {
    border-radius: 8px;
}
.skeleton-chart {
    border-radius: 8px;
}
.skeleton-table {
    border-radius: 8px;
}
.card-loaded .skeleton {
    display: none;
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Skeleton inside chart-container needs relative positioning */
.chart-container {
    position: relative;
}

/* ─── 3. Accessibility WCAG 2.2 AA ─────────────────── */
.skip-link {
    position: absolute;
    top: -50px;
    left: 16px;
    background: var(--cyan);
    color: #fff;
    padding: 8px 16px;
    border-radius: 0 0 8px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 9999;
    transition: top 0.2s;
    text-decoration: none;
}
.skip-link:focus {
    top: 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 2px;
}

/* Remove outline for mouse users */
:focus:not(:focus-visible) {
    outline: none;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .bg-glow { animation: none !important; }
    .skeleton { animation: none !important; background: var(--bg-card-hover); }
}

/* ─── 4. Filter Pills ─────────────────────────────── */
.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 20px;
    margin-bottom: 8px;
    min-height: 0;
    transition: min-height 0.3s var(--ease);
}
.filter-pills:empty {
    margin-bottom: 0;
}
.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px 3px 10px;
    border-radius: 20px;
    background: rgba(6, 182, 212, 0.08);
    border: 1px solid rgba(6, 182, 212, 0.15);
    color: var(--cyan);
    font-size: 0.65rem;
    font-weight: 500;
    white-space: nowrap;
    animation: pillIn 0.2s var(--ease);
}
@keyframes pillIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}
.pill-label {
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    font-size: 0.55rem;
    letter-spacing: 0.04em;
}
.pill-remove {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--cyan);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    line-height: 1;
    padding: 0;
    transition: all 0.15s;
}
.pill-remove:hover {
    background: rgba(6, 182, 212, 0.15);
    color: var(--text);
}
.save-filters-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--text-3);
    font-size: 0.6rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}
.save-filters-btn:hover {
    border-color: var(--cyan);
    color: var(--cyan);
}
.saved-combos {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.saved-combo-btn {
    padding: 3px 8px;
    border-radius: 20px;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.15);
    color: var(--purple);
    font-size: 0.6rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}
.saved-combo-btn:hover {
    background: rgba(139, 92, 246, 0.15);
}
.saved-combo-del {
    margin-left: 4px;
    padding: 0 3px;
    border: none;
    background: transparent;
    color: var(--purple);
    cursor: pointer;
    font-size: 0.7rem;
    opacity: 0;
    transition: opacity 0.15s;
}
.saved-combo-btn:hover .saved-combo-del {
    opacity: 0.7;
}
.saved-combo-del:hover {
    opacity: 1 !important;
}

/* ─── 5. Drill-down Breadcrumb ─────────────────────── */
.breadcrumb {
    padding: 0 20px;
    margin-bottom: 8px;
    font-size: 0.7rem;
    color: var(--text-2);
    display: flex;
    align-items: center;
    gap: 0;
}
.breadcrumb[hidden] {
    display: none;
}
.breadcrumb-item {
    cursor: pointer;
    padding: 2px 0;
    transition: color 0.15s;
}
.breadcrumb-item:hover {
    color: var(--cyan);
}
.breadcrumb-item.active {
    color: var(--text);
    font-weight: 600;
    cursor: default;
}
.breadcrumb-sep {
    margin: 0 6px;
    color: var(--text-3);
    font-size: 0.6rem;
}

/* ─── 6. Export Menu ──────────────────────────────── */
.export-menu {
    position: relative;
}
.btn-export {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s var(--ease);
    flex-shrink: 0;
}
.btn-export:hover {
    border-color: var(--cyan);
    color: var(--cyan);
    background: rgba(6, 182, 212, 0.06);
}
.export-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px;
    z-index: 50;
    min-width: 100px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
.export-dropdown[hidden] {
    display: none;
}
.export-opt {
    display: block;
    width: 100%;
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.68rem;
    font-family: 'Inter', sans-serif;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s;
}
.export-opt:hover {
    background: rgba(6, 182, 212, 0.08);
    color: var(--cyan);
}
[data-theme="light"] .export-dropdown {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* ─── 7. Colorblind — patterns handled by JS (patternomaly) ─── */

/* ─── 8. AI Insights Row ──────────────────────────── */
.insights-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--gap);
    margin-bottom: var(--gap);
    padding: 0;
}
.insights-row:empty {
    display: none;
}
.insight-card {
    padding: 14px 18px;
    border-radius: var(--radius);
    background: var(--bg-card);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border);
    border-left: 3px solid var(--text-3);
    transition: all 0.3s var(--ease);
}
.insight-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-1px);
}
.insight-card.positive { border-left-color: var(--green); }
.insight-card.negative { border-left-color: var(--red); }
.insight-card.neutral { border-left-color: var(--amber); }

.insight-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}
.insight-card.positive .insight-title { color: var(--green); }
.insight-card.negative .insight-title { color: var(--red); }
.insight-card.neutral .insight-title { color: var(--amber); }

.insight-body {
    font-size: 0.75rem;
    color: var(--text-2);
    line-height: 1.4;
}

/* ─── 9. NLQ Search Bar ──────────────────────────── */
.nlq-bar {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 20px;
    margin-bottom: var(--gap);
    flex-wrap: wrap;
}
.nlq-icon {
    color: var(--text-3);
    flex-shrink: 0;
    display: flex;
    margin-top: 2px;
}
.nlq-bar input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 0.8rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    min-width: 200px;
}
.nlq-bar input:disabled {
    opacity: 0.5;
}
.nlq-bar input::placeholder {
    color: var(--text-3);
}
.nlq-clear {
    background: none;
    border: none;
    color: var(--text-3);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
    transition: color .15s;
}
.nlq-clear:hover { color: var(--text); }
.nlq-feedback {
    font-size: 0.65rem;
    color: var(--cyan);
    white-space: nowrap;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nlq-feedback.nlq-answer {
    white-space: normal;
    max-width: 100%;
    width: 100%;
    font-size: 0.75rem;
    color: var(--text);
    line-height: 1.5;
    padding: 10px 14px;
    margin-top: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: visible;
}
.nlq-feedback.nlq-loading {
    color: var(--cyan);
    animation: nlq-pulse 1.2s ease-in-out infinite;
}
.nlq-feedback.nlq-error {
    color: var(--red, #ef4444);
}
@keyframes nlq-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ─── 10. Alert Panel ─────────────────────────────── */
.alerts-panel {
    position: relative;
    z-index: 100;
}
.alerts-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    backdrop-filter: blur(var(--glass-blur));
    color: var(--text-2);
    cursor: pointer;
    font-size: 0.7rem;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s var(--ease);
}
.alerts-toggle:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
}
.alerts-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: var(--text-3);
    color: var(--bg);
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0 4px;
}
.alerts-count.has-alerts {
    background: var(--red);
    color: #fff;
}
.alerts-list {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    width: 300px;
    max-height: 350px;
    overflow-y: auto;
    padding: 8px;
    border-radius: var(--radius);
    z-index: 9999;
}
.alerts-list[hidden] {
    display: none;
}
.alert-item {
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--bg-card);
    border-left: 3px solid var(--text-3);
    margin-bottom: 6px;
    font-size: 0.7rem;
    color: var(--text-2);
    line-height: 1.4;
}
.alert-item:last-child { margin-bottom: 0; }
.alert-item.danger { border-left-color: var(--red); }
.alert-item.warning { border-left-color: var(--amber); }
.alert-item.info { border-left-color: var(--cyan); }
.alert-name {
    font-weight: 600;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 3px;
}
.alert-item.danger .alert-name { color: var(--red); }
.alert-item.warning .alert-name { color: var(--amber); }
.alert-item.info .alert-name { color: var(--cyan); }

/* ─── 11. Heatmap ────────────────────────────────── */
.heatmap-container {
    width: 100%;
    overflow-x: auto;
    padding: 4px 0;
    max-width: 100%;
}
.heatmap-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 2px;
    font-size: 0.62rem;
    font-family: 'Inter', sans-serif;
}
.heatmap-table th {
    padding: 4px 6px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    font-size: 0.55rem;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.heatmap-table th.heatmap-marca {
    text-align: left;
    min-width: 90px;
}
.heatmap-cell {
    padding: 5px 4px;
    text-align: center;
    border-radius: 4px;
    font-weight: 500;
    color: var(--text);
    transition: transform 0.15s, box-shadow 0.15s;
    cursor: default;
    min-width: 48px;
}
.heatmap-cell:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    z-index: 2;
    position: relative;
}
.heatmap-marca-cell {
    text-align: left;
    font-weight: 600;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
    padding: 4px 6px;
}

/* ─── 12. Treemap ────────────────────────────────── */
.treemap-container {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    width: 100%;
    height: 100%;
    min-height: 200px;
    padding: 4px;
}
.treemap-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    padding: 8px 6px;
    cursor: default;
    transition: filter 0.2s, transform 0.15s;
    overflow: hidden;
    text-align: center;
    min-width: 60px;
}
.treemap-item:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
}
.treemap-item-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
    line-height: 1.2;
    word-break: break-word;
}
.treemap-item-value {
    font-size: 0.58rem;
    font-weight: 500;
    color: rgba(255,255,255,0.85);
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    margin-top: 2px;
}
.treemap-item-mg {
    font-size: 0.5rem;
    font-weight: 700;
    color: rgba(255,255,255,0.95);
    margin-top: 1px;
}

/* ─── 13. KPI Target Bars (#6) — hidden, cards show data only ── */
.kpi-target {
    display: none !important;
}
.kpi-target:empty {
    display: none;
}
.progress-bar-bg {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    overflow: hidden;
    position: relative;
}
.progress-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 1s ease-out, background-color 0.3s;
    max-width: 100%;
}
.target-label {
    font-size: 0.55rem;
    font-weight: 600;
    white-space: nowrap;
    min-width: 55px;
    text-align: right;
}

/* ─── 14. Table Search + Sort (#8) ───────────────── */
.table-search {
    display: block;
    width: 100%;
    padding: 6px 10px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font-size: 0.68rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}
.table-search:focus {
    border-color: var(--cyan);
}
.table-search::placeholder {
    color: var(--text-3);
}
.th-sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
    position: relative;
}
.th-sortable:hover {
    color: var(--cyan);
}
.th-sortable::after {
    content: '';
    margin-left: 3px;
    font-size: 0.55rem;
    opacity: 0.4;
}
.th-sortable.sort-asc::after {
    content: ' ▲';
    opacity: 1;
    color: var(--cyan);
}
.th-sortable.sort-desc::after {
    content: ' ▼';
    opacity: 1;
    color: var(--cyan);
}

/* ─── 15. Executive Summary (#9) ─────────────────── */
.exec-summary {
    padding: 16px 20px;
    margin: 0 0 var(--gap) 0;
    border-left: 3px solid var(--cyan);
    border-radius: var(--radius);
    max-width: 100%;
    overflow: hidden;
    word-wrap: break-word;
}
.exec-summary[hidden] {
    display: none;
}
.exec-summary-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--cyan);
    margin-bottom: 6px;
}
.exec-summary-text {
    font-size: 0.78rem;
    line-height: 1.6;
    color: var(--text-2);
    margin: 0;
}
.exec-highlight {
    font-weight: 600;
    color: var(--text);
}
/* Structured bullet list */
.exec-bullets {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.exec-bullet {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.78rem;
    line-height: 1.55;
    color: var(--text-2);
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(255,255,255,0.02);
    border-left: 3px solid var(--text-3);
}
.exec-bullet.positive { border-left-color: var(--green); }
.exec-bullet.negative { border-left-color: var(--red); }
.exec-bullet.opportunity { border-left-color: var(--amber); }
.exec-bullet-icon {
    flex-shrink: 0;
    font-size: 0.6rem;
    line-height: 1.55;
    padding-top: 2px;
}
.exec-bullet.positive .exec-bullet-icon { color: var(--green); }
.exec-bullet.negative .exec-bullet-icon { color: var(--red); }
.exec-bullet.opportunity .exec-bullet-icon { color: var(--amber); }
@media (max-width: 600px) {
    .exec-bullet { font-size: 0.72rem; padding: 5px 8px; }
}

/* ─── 16. ML Analytics Section ───────────────────── */
.analytics-section {
    margin-top: calc(var(--gap) * 2);
    padding-top: var(--gap);
    border-top: 1px solid var(--border);
}
.analytics-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: var(--gap);
    padding: 0 4px;
}
.analytics-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}
.analytics-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(139, 92, 246, 0.12);
    border: 1px solid rgba(139, 92, 246, 0.25);
    color: var(--purple);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.analytics-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: var(--gap);
    margin-bottom: var(--gap);
}
.analytics-row-3 {
    grid-template-columns: 1fr 1fr 1fr;
}
.analytics-card {
    padding: 16px;
    min-height: 200px;
}
.analytics-card .card-header {
    margin-bottom: 12px;
}
.analytics-card .card-header h3 {
    font-size: 0.78rem;
}
.analytics-wide {
    min-height: 280px;
}

/* Forecast meta */
.forecast-meta {
    display: flex;
    gap: 16px;
    margin-bottom: 8px;
    font-size: 0.65rem;
    color: var(--text-3);
}
.forecast-metric {
    display: flex;
    align-items: center;
    gap: 4px;
}
.forecast-metric strong {
    color: var(--text-2);
}

/* Anomalies list */
.anomalies-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 320px;
    overflow-y: auto;
}
.anomaly-item {
    padding: 10px 12px;
    border-radius: 8px;
    border-left: 3px solid var(--text-3);
    background: rgba(255,255,255,0.02);
    font-size: 0.7rem;
    color: var(--text-2);
    line-height: 1.4;
}
.anomaly-item.high { border-left-color: var(--red); }
.anomaly-item.medium { border-left-color: var(--amber); }
.anomaly-item.info { border-left-color: var(--cyan); }
.anomaly-badge {
    display: inline-block;
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}
.anomaly-item.high .anomaly-badge { color: var(--red); }
.anomaly-item.medium .anomaly-badge { color: var(--amber); }
.anomaly-item.info .anomaly-badge { color: var(--cyan); }
.anomaly-zscore {
    font-size: 0.6rem;
    color: var(--text-3);
    float: right;
}

/* ABC Classification */
.abc-bar-container {
    margin-bottom: 10px;
}
.abc-bar {
    display: flex;
    height: 28px;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
}
.abc-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    font-weight: 600;
    color: #fff;
    transition: flex-basis 0.6s ease;
    min-width: 30px;
}
.abc-segment.a { background: var(--green); }
.abc-segment.b { background: var(--amber); }
.abc-segment.c { background: var(--text-3); }
.abc-legend {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.abc-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.62rem;
    color: var(--text-2);
}
.abc-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
}
.abc-dot.a { background: var(--green); }
.abc-dot.b { background: var(--amber); }
.abc-dot.c { background: var(--text-3); }
.abc-items {
    margin-top: 8px;
    font-size: 0.65rem;
    color: var(--text-3);
    line-height: 1.5;
}
.abc-items strong {
    color: var(--text-2);
}

/* Momentum bars */
.momentum-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.momentum-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.68rem;
}
.momentum-label {
    width: 100px;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-2);
    font-weight: 500;
    flex-shrink: 0;
}
.momentum-bar-wrap {
    flex: 1;
    height: 14px;
    background: var(--border);
    border-radius: 3px;
    position: relative;
    overflow: hidden;
}
.momentum-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.8s ease;
    position: absolute;
    top: 0;
}
.momentum-bar.positive {
    left: 50%;
    background: var(--green);
}
.momentum-bar.negative {
    right: 50%;
    background: var(--red);
}
.momentum-center {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--text-3);
}
.momentum-value {
    width: 50px;
    text-align: left;
    font-weight: 600;
    font-size: 0.62rem;
    flex-shrink: 0;
}
.momentum-value.up { color: var(--green); }
.momentum-value.down { color: var(--red); }
.momentum-value.stable { color: var(--text-3); }

/* Correlations */
.correlation-item {
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(255,255,255,0.02);
    margin-bottom: 6px;
}
.correlation-pair {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}
.correlation-value {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.58rem;
    font-weight: 700;
    margin-left: 6px;
}
.correlation-value.strong { background: rgba(16,185,129,0.12); color: var(--green); }
.correlation-value.moderate { background: rgba(245,158,11,0.12); color: var(--amber); }
.correlation-interp {
    font-size: 0.65rem;
    color: var(--text-3);
    line-height: 1.4;
    margin-top: 2px;
}

/* Seasonality */
.seasonality-info {
    font-size: 0.65rem;
    color: var(--text-3);
    margin-bottom: 8px;
}
.seasonality-info strong { color: var(--text-2); }

/* ─── 17. User Menu ─────────────────────────────── */
.user-menu { position: relative; }
.user-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #df6d9a, #0e9eb5);
    border: none;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s;
}
.user-avatar:hover { opacity: 0.85; }
.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 240px;
    padding: 16px;
    z-index: 200;
    border-radius: 12px;
}
.user-dropdown-header { margin-bottom: 4px; }
.user-dropdown-name { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.user-dropdown-email { font-size: 0.7rem; color: var(--text-3); margin-bottom: 6px; }
.user-dropdown-team {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 600;
}
.badge-admin { background: rgba(223,109,154,0.2); color: #df6d9a; }
.badge-g_general { background: rgba(14,158,181,0.2); color: #0e9eb5; }
.badge-marketing { background: rgba(255,181,3,0.2); color: #ffb503; }
.badge-operaciones { background: rgba(16,185,129,0.2); color: #10b981; }
.badge-finanzas { background: rgba(99,102,241,0.2); color: #6366f1; }
.user-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 10px 0;
}
.user-dropdown-item {
    display: block;
    padding: 6px 0;
    font-size: 0.8rem;
    color: var(--text-2);
    text-decoration: none;
    transition: color 0.15s;
}
.user-dropdown-item:hover { color: var(--text); }
.user-dropdown-logout { color: #f87171; }
.user-dropdown-logout:hover { color: #ef4444; }

/* ─── Responsive for new components ──────────────── */
@media (max-width: 900px) {
    .alerts-list { width: 260px; }
    .insights-row { grid-template-columns: 1fr; }
    .nlq-bar { padding: 8px 14px; }
    .analytics-row { grid-template-columns: 1fr; }
    .analytics-row-3 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .alerts-toggle { padding: 6px 10px; font-size: 0.65rem; }
    .alerts-list { width: 240px; }
    .filter-pills { padding: 0 12px; }
    .breadcrumb { padding: 0 12px; font-size: 0.65rem; }
    .nlq-bar { padding: 8px 12px; gap: 8px; }
    .nlq-bar input { font-size: 0.72rem; }
    .insight-card { padding: 10px 14px; }
    .insight-body { font-size: 0.7rem; }
    .export-dropdown { min-width: 90px; }
    .exec-summary { padding: 12px 14px; }
    .exec-summary-text { font-size: 0.72rem; }
    .heatmap-table { font-size: 0.55rem; }
    .treemap-item { min-width: 50px; padding: 6px 4px; }
    .opd-banner { flex-direction: column; gap: 8px; padding: 10px 14px; }
}

/* ─── OPD Banner ────────────────────────────────────── */
.opd-banner {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 24px; margin: 0 auto 16px; max-width: 1400px;
    border-left: 4px solid #f59e0b;
}
.opd-info { display: flex; align-items: center; gap: 12px; font-size: 0.78rem; }
.opd-info strong { color: var(--text-1); }
.opd-info span { color: var(--text-3); font-size: 0.72rem; }
.opd-right { display: flex; align-items: center; gap: 18px; }
.opd-toggle-label {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.72rem; color: var(--text-2); cursor: pointer; user-select: none;
}
.opd-toggle-label input { display: none; }
.opd-slider {
    position: relative; width: 36px; height: 20px;
    background: var(--bg-3); border-radius: 10px; transition: background 0.2s;
}
.opd-slider::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px; background: #fff; border-radius: 50%;
    transition: transform 0.2s;
}
.opd-toggle-label input:checked + .opd-slider { background: #f59e0b; }
.opd-toggle-label input:checked + .opd-slider::after { transform: translateX(16px); }
.opd-banner[hidden] { display: none !important; }
.kpi-opd-note {
    display: block; font-size: 0.62rem; color: #f59e0b;
    margin-top: 2px; font-weight: 500;
}
.kpi-opd-note[hidden] { display: none !important; }

/* ═══════════════════════════════════════════════
   AI CHAT PANEL (floating)
   ═══════════════════════════════════════════════ */
.chat-fab {
    position: fixed; bottom: 28px; right: 28px; z-index: 9000;
    width: 52px; height: 52px; border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none; cursor: pointer; color: #fff; font-size: 22px;
    box-shadow: 0 4px 20px rgba(99,102,241,0.45);
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}
.chat-fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(99,102,241,0.6); }
.chat-fab.open { background: linear-gradient(135deg, #4b5563, #374151); }

.chat-panel {
    position: fixed; bottom: 90px; right: 28px; z-index: 8999;
    width: 360px; max-height: 520px;
    background: var(--bg-card, #1a1a2e); border: 1px solid var(--border, rgba(255,255,255,0.1));
    border-radius: 16px; box-shadow: 0 16px 48px rgba(0,0,0,0.4);
    display: flex; flex-direction: column; overflow: hidden;
    transform-origin: bottom right;
    animation: chatIn 0.22s cubic-bezier(0.34,1.56,0.64,1);
}
.chat-panel[hidden] { display: none !important; }
@keyframes chatIn {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}
.chat-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px 12px;
    background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(139,92,246,0.15));
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
    flex-shrink: 0;
}
.chat-panel-title {
    font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em;
    color: var(--text-1, #e8e8f0); display: flex; align-items: center; gap: 7px;
}
.chat-panel-title .chat-sparkle { color: #a78bfa; font-size: 15px; }
.chat-panel-close {
    background: none; border: none; cursor: pointer; color: var(--text-3, #888);
    font-size: 18px; line-height: 1; padding: 2px 4px; border-radius: 4px;
    transition: color 0.15s; display: flex; align-items: center;
}
.chat-panel-close:hover { color: var(--text-1, #e8e8f0); }
.chat-messages {
    flex: 1; overflow-y: auto; padding: 14px 14px 8px;
    display: flex; flex-direction: column; gap: 10px;
    scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border, rgba(255,255,255,0.12)); border-radius: 2px; }
.chat-msg {
    max-width: 88%; font-size: 0.76rem; line-height: 1.5;
    padding: 9px 13px; border-radius: 12px; animation: msgIn 0.18s ease;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.chat-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    color: #fff; border-bottom-right-radius: 4px;
}
.chat-msg.ai {
    align-self: flex-start;
    background: var(--bg-3, rgba(255,255,255,0.06));
    color: var(--text-1, #e8e8f0); border-bottom-left-radius: 4px;
    border: 1px solid var(--border, rgba(255,255,255,0.07));
}
.chat-msg.thinking {
    align-self: flex-start; color: var(--text-3, #888);
    background: transparent; border: none; padding: 4px 0;
    font-style: italic; font-size: 0.72rem;
}
.chat-empty {
    text-align: center; color: var(--text-3, #666);
    font-size: 0.72rem; margin-top: 20px; line-height: 1.7;
}
.chat-empty .chat-empty-icon { font-size: 28px; margin-bottom: 6px; }
.chat-input-row {
    display: flex; gap: 8px; padding: 10px 12px 12px;
    border-top: 1px solid var(--border, rgba(255,255,255,0.08));
    flex-shrink: 0;
}
.chat-input {
    flex: 1; background: var(--bg-3, rgba(255,255,255,0.05));
    border: 1px solid var(--border, rgba(255,255,255,0.1));
    border-radius: 8px; color: var(--text-1, #e8e8f0);
    font-size: 0.76rem; font-family: inherit; padding: 8px 11px;
    outline: none; transition: border-color 0.15s;
}
.chat-input:focus { border-color: #6366f1; }
.chat-input::placeholder { color: var(--text-3, #666); }
.chat-send {
    background: #6366f1; border: none; border-radius: 8px;
    color: #fff; cursor: pointer; font-size: 16px; padding: 0 12px;
    transition: background 0.15s; display: flex; align-items: center;
}
.chat-send:hover { background: #4f46e5; }
.chat-send:disabled { background: #4b5563; cursor: not-allowed; }
.chat-clear-btn {
    background: none; border: none; color: var(--text-3, #888);
    font-size: 0.65rem; cursor: pointer; padding: 2px 6px;
    text-align: center; margin: 0 auto 4px; display: block;
    text-decoration: underline; transition: color 0.15s;
}
.chat-clear-btn:hover { color: var(--text-2, #aaa); }
