/* Fliq-inspired Modern Sales Funnel - 3 Funnels Layout */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    color: #2c3e50;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.dashboard {
    min-height: 100vh;
    background: #f5f7fa;
    overflow-x: hidden;
}

.top-bar {
    background: #ffffff;
    padding: 1.5rem 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border-bottom: 1px solid #e8ecef;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}

.top-bar h1 {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.top-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    width: 100%;
}

.stat-box {
    background: #ffffff;
    border-radius: 8px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid #e8ecef;
    transition: all 0.2s;
}

.stat-box.positive .stat-icon {
    background: #27ae60 !important;
}

.stat-box.negative .stat-icon {
    background: #e74c3c !important;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #3498db !important;
}

.stat-label {
    font-size: 0.75rem;
    color: #7f8c8d;
    font-weight: 500;
    text-transform: uppercase;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    color: #2c3e50;
}

.filters-bar {
    background: #fff;
    padding: 1.5rem 2rem;
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    border-bottom: 1px solid #e8ecef;
}

.filter-item {
    flex: 1;
    min-width: 180px;
}

.filter-item label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #7f8c8d;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.filter-item select {
    width: 100%;
    padding: 0.625rem 1rem;
    border: 1px solid #e8ecef;
    border-radius: 6px;
    font-size: 0.875rem;
    background: #fff;
    color: #2c3e50;
}

.main-content {
    padding: 2rem;
}

.funnel-section {
    background: #fff;
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid #e8ecef;
}

.funnel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.funnel-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.funnel-legend {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.legend-item span {
    font-size: 0.75rem;
    color: #7f8c8d;
}

.funnels-container {
    display: flex;
    gap: 1.5rem;
    align-items: stretch;
    justify-content: center;
    margin-top: 2rem;
}

.main-funnel-wrapper,
.mini-funnel-wrapper {
    flex: 1;
    text-align: center;
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid #e8ecef;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
}

.mini-funnel-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.mini-funnel-header h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0;
    color: #2c3e50;
}

.data-source-note {
    font-size: 0.7rem;
    color: #95a5a6;
    font-style: italic;
    margin-top: 0.25rem;
}

.nav-btn {
    background: #f8f9fa;
    border: 1px solid #e8ecef;
    color: #7f8c8d;
    font-size: 1.25rem;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
}

.nav-btn:hover:not(:disabled) {
    background: #3498db;
    border-color: #3498db;
    color: white;
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.mini-funnel-svg {
    width: 100%;
    height: 500px;
    flex: 1;
}

.mini-stage-info {
    font-size: 16px;
    font-weight: 600;
    fill: white;
    pointer-events: none;
}

.main-funnel-wrapper h3,
.mini-funnel-wrapper h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.funnel-svg {
    width: 100%;
    height: 500px;
    flex: 1;
}

.funnel-stage-group {
    cursor: pointer;
}

.funnel-path {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.08));
}

.stage-name {
    font-size: 18px;
    font-weight: 600;
    fill: white;
    pointer-events: none;
}

.stage-info {
    font-size: 14px;
    font-weight: 500;
    fill: white;
    pointer-events: none;
}

.charts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

@media (max-width: 1024px) {
    .charts-section {
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
    }
}

.chart-card {
    background: #fff;
    border-radius: 8px;
    padding: 2rem;
    border: 1px solid #e8ecef;
    display: flex;
    flex-direction: column;
}

.chart-card h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
}

.chart-hint {
    font-size: 0.75rem;
    color: #95a5a6;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
}

.chart-card canvas {
    width: 100% !important;
    height: 350px !important;
    flex-shrink: 0;
}

.stage-details {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e8ecef;
}

.stage-details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.stage-details-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.close-stage-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: #7f8c8d;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
}

.close-stage-btn:hover {
    color: #2c3e50;
}

.opportunities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.opp-card {
    background: #fff;
    border: 1px solid #e8ecef;
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.opp-card:hover {
    border-color: #3498db;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.1);
}

.opp-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.opp-card-header h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.opp-value {
    font-size: 1rem;
    font-weight: 700;
    color: #27ae60;
    white-space: nowrap;
    margin-left: 0.5rem;
}

.opp-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.opp-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #7f8c8d;
}

.opp-info svg {
    flex-shrink: 0;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-card {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e8ecef;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.close-btn {
    background: transparent;
    border: none;
    font-size: 2rem;
    color: #7f8c8d;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #2c3e50;
}

.modal-body {
    padding: 2rem;
}

.modal-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.modal-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.modal-item.full {
    grid-column: 1 / -1;
}

.modal-item label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #7f8c8d;
    text-transform: uppercase;
}

.modal-item span {
    font-size: 1rem;
    color: #2c3e50;
}

.modal-item .highlight {
    font-size: 1.5rem;
    font-weight: 700;
    color: #27ae60;
}

.modal-history h4 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.history-timeline {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.history-item {
    display: flex;
    gap: 1rem;
    position: relative;
}

.history-dot {
    width: 12px;
    height: 12px;
    background: #3498db;
    border-radius: 50%;
    margin-top: 0.25rem;
    flex-shrink: 0;
}

.history-content {
    flex: 1;
}

.history-date {
    font-size: 0.75rem;
    color: #7f8c8d;
    margin-bottom: 0.25rem;
}

.history-action {
    font-size: 0.875rem;
    color: #2c3e50;
}

/* New Enhancement Styles */

/* Priority Badges */
.priority-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

.priority-badge.must-win {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.priority-badge.target {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* BID Status Badges */
.bid-status-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
}

.bid-status-yes {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.bid-status-no {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.bid-status-pending {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

/* Segment Badge */
.segment-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 600;
    background: #e3f2fd;
    color: #1565c0;
    border: 1px solid #bbdefb;
    margin-left: 0.5rem;
}

/* Days Warning */
.days-warning {
    color: #e74c3c;
    font-weight: 600;
}

/* Filter adjustments for more filters */
.filter-item {
    flex: 1;
    min-width: 150px;
}

/* Chart Toggle Buttons */
.chart-toggle-buttons {
    display: flex;
    gap: 0.5rem;
    background: #f8f9fa;
    padding: 0.25rem;
    border-radius: 6px;
    border: 1px solid #e8ecef;
}

.chart-toggle-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #7f8c8d;
    cursor: pointer;
    transition: all 0.2s;
}

.chart-toggle-btn:hover {
    background: #e8ecef;
    color: #2c3e50;
}

.chart-toggle-btn.active {
    background: #3498db;
    color: white;
}

.mini-funnel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.mini-funnel-header h4 {
    flex: 1 1 auto;
    min-width: 100px;
}

@media (max-width: 768px) {
    .mini-funnel-header {
        justify-content: center;
        text-align: center;
    }
    
    .mini-funnel-header h4 {
        width: 100%;
        flex: 1 1 100%;
    }
    
    .mini-funnel-header > div {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* Fix for Chart.js canvas sizing */
.history-chart canvas {
    max-width: 100% !important;
    height: auto !important;
}

.history-chart > div {
    position: relative !important;
    width: 100% !important;
}

/* Responsive Design - Stack funnels on narrower screens */
@media (max-width: 1400px) {
    .funnels-container {
        flex-direction: column;
    }
    
    .main-funnel-wrapper,
    .mini-funnel-wrapper {
        width: 100%;
        max-width: 100%;
    }
    
    .funnel-svg,
    .mini-funnel-svg {
        height: 400px;
    }
}


@media (max-width: 768px) {
    .top-stats {
        grid-template-columns: 1fr;
    }
    
    .filters-bar {
        flex-direction: column;
    }
    
    .filter-item {
        width: 100%;
    }
    
    .funnel-legend {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .funnel-section {
        padding: 1rem;
    }
    
    .chart-card {
        padding: 1rem;
    }
    
    .opportunities-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .top-bar {
        padding: 1rem;
    }
    
    .top-bar h1 {
        font-size: 1.25rem;
    }
    
    .stat-box {
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
}
