/* CSS Variables for Theme */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d29;
    --bg-card: #252836;
    --bg-hover: #2d3142;
    
    --text-primary: #ffffff;
    --text-secondary: #a0a4b8;
    --text-muted: #6b7280;
    
    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --accent-purple: #8b5cf6;
    --accent-pink: #ec4899;
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --border-color: #374151;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    padding: 1rem 0;
}

.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo .subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.nav {
    display: flex;
    gap: 1.5rem;
}

.nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

.nav a:hover,
.nav a.active {
    color: var(--accent-blue);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--success);
    font-size: 0.875rem;
}

.live-indicator .dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.date-range {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
}

/* Main Content */
.main {
    margin-top: 80px;
    padding: 2rem 0;
}

/* Footer */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    margin-top: 3rem;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.last-update {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer-actions {
    display: flex;
    gap: 1rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

/* Sections */
.section {
    padding: 2.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.section:first-child {
    padding-top: 1.5rem;
}

.section:last-child {
    border-bottom: none;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-title::before {
    content: '';
    width: 4px;
    height: 22px;
    background: linear-gradient(180deg, var(--accent-blue), var(--accent-cyan));
    border-radius: 2px;
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--bg-card);
    border-radius: 0.5rem;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 0.25rem;
}

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

.card-title {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.card-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.375rem;
    word-break: break-word;
    line-height: 1.2;
}

.card-trend {
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.trend-up {
    color: var(--success);
}

.trend-down {
    color: var(--danger);
}

/* Charts */
.chart-container {
    background: var(--bg-card);
    border-radius: 0.5rem;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.chart-container canvas {
    max-height: 180px;
}

.chart-title {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.charts-row .chart-container {
    margin-bottom: 0;
}

/* Chart size variants */
.chart-sm canvas { max-height: 140px; }
.chart-md canvas { max-height: 180px; }
.chart-lg canvas { max-height: 220px; }

/* Tables */
.table-container {
    background: var(--bg-card);
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.75rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: var(--bg-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

td {
    font-size: 0.8rem;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background: var(--bg-hover);
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid var(--warning);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid var(--accent-blue);
}

.alert-icon {
    font-size: 1.25rem;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.125rem;
}

.alert-message {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Priority Badge */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-high {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.badge-medium {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.badge-low {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.tab-button {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s;
    border-radius: 0.25rem 0.25rem 0 0;
}

.tab-button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.tab-button.active {
    background: var(--bg-card);
    color: var(--accent-blue);
    border: 1px solid var(--border-color);
    border-bottom: none;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tab-content .chart-container {
    margin-bottom: 0;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section {
    animation: fadeIn 0.5s ease-out;
}

.card, .chart-container, .table-container {
    animation: fadeIn 0.3s ease-out;
}

/* Scroll to top */
.scroll-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent-blue);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    box-shadow: var(--shadow);
    transition: all 0.3s;
    z-index: 999;
}

.scroll-top:hover {
    background: #2563eb;
    transform: translateY(-2px);
}

/* Responsive */
@media (max-width: 1024px) {
    .nav {
        display: none;
    }
    
    .charts-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
    
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .header-actions {
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 1rem;
    }
}

/* ==================== SCORING CARDS ==================== */

.card-score-low { border-left: 4px solid #22c55e; }
.card-score-medium { border-left: 4px solid #f59e0b; }
.card-score-high { border-left: 4px solid #ef4444; }

.score-bar {
    height: 8px;
    background: #374151;
    border-radius: 4px;
    margin-top: 8px;
    overflow: hidden;
}

.score-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.score-fill.low { background: linear-gradient(90deg, #22c55e, #4ade80); }
.score-fill.medium { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.score-fill.high { background: linear-gradient(90deg, #ef4444, #f87171); }

/* ==================== CLASSIFICATION BADGES ==================== */

.badge-churn { background: #ef4444; color: white; }
.badge-retention { background: #22c55e; color: white; }
.badge-upsell { background: #8b5cf6; color: white; }
.badge-longterm { background: #3b82f6; color: white; }
.badge-mediumterm { background: #60a5fa; color: white; }
.badge-shortterm { background: #93c5fd; color: white; }
.badge-vip { background: #8b5cf6; color: white; }
.badge-medium-value { background: #a78bfa; color: white; }
.badge-small { background: #c4b5fd; color: white; }
.badge-lowrisk { background: #22c55e; color: white; }
.badge-mediumrisk { background: #f59e0b; color: white; }
.badge-highrisk { background: #ef4444; color: white; }
.badge-critical { background: #991b1b; color: white; }
.badge-poweruser { background: #f59e0b; color: white; }
.badge-regular { background: #60a5fa; color: white; }
.badge-casual { background: #94a3b8; color: white; }
.badge-dormant { background: #64748b; color: white; }
.badge-enterprise { background: #7c3aed; color: white; }
.badge-team { background: #8b5cf6; color: white; }
.badge-individual { background: #a78bfa; color: white; }
.badge-success { background: #22c55e; color: white; }
.badge-warning { background: #f59e0b; color: white; }
.badge-danger { background: #ef4444; color: white; }

/* ==================== CLASSIFICATION TABS ==================== */

.classification-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.classification-tab {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.classification-tab:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.classification-tab.active {
    background: var(--accent-blue);
    color: white;
}

.classification-stats {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.stat-item .stat-label {
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.stat-item .stat-count {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-blue);
}

.stat-item .stat-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ==================== TIMELINE STYLES ==================== */

.timeline-visual {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    position: relative;
}

.timeline-visual::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 10%;
    right: 10%;
    height: 4px;
    background: #374151;
    z-index: 0;
}

.timeline-phase {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
    flex: 1;
}

.phase-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    background: var(--bg-card);
    border: 3px solid #374151;
}

.phase-icon.completed { background: #22c55e; border-color: #22c55e; color: white; }
.phase-icon.current { background: #3b82f6; border-color: #3b82f6; color: white; animation: pulseGlow 2s infinite; }
.phase-icon.pending { background: var(--bg-card); border-color: #374151; color: #64748b; }

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
}

.phase-label {
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    font-size: 0.875rem;
}

.phase-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.phase-arrow {
    color: #4b5563;
    font-size: 1.5rem;
    position: relative;
    z-index: 1;
}

.phase-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.phase-action-item {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.phase-action-item h4 {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.phase-action-item ul {
    margin: 0;
    padding-left: 1.25rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.phase-action-item li {
    margin-bottom: 0.25rem;
}

/* ==================== ACCORDION STYLES ==================== */

.accordion {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.accordion-item {
    border-bottom: 1px solid var(--border-color);
}

.accordion-item:last-child {
    border-bottom: none;
}

.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--bg-card);
    cursor: pointer;
    transition: background 0.2s;
}

.accordion-header:hover {
    background: var(--bg-hover);
}

.accordion-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.accordion-title strong {
    color: var(--text-primary);
}

.accordion-expand {
    transition: transform 0.2s;
    color: var(--text-secondary);
}

.accordion-item.open .accordion-expand {
    transform: rotate(180deg);
}

.accordion-content {
    display: none;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.accordion-item.open .accordion-content {
    display: block;
}

.accordion-detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.accordion-detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.accordion-detail-item .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.accordion-detail-item .value {
    font-weight: 600;
    color: var(--text-primary);
    word-wrap: break-word;
    white-space: normal;
}

/* ==================== ACTION MATRIX ==================== */

.action-matrix-table {
    width: 100%;
    border-collapse: collapse;
}

.action-matrix-table th,
.action-matrix-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    word-wrap: break-word;
    white-space: normal;
    max-width: 200px;
}

.action-matrix-table tr:hover {
    background: var(--bg-hover);
}

.priority-stars {
    color: #fbbf24;
    letter-spacing: 2px;
}

/* ==================== SCORING BREAKDOWN ==================== */

.scoring-breakdown {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.score-item {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
}

.score-item h4 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.score-item .score-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.score-item .score-value.low { color: #22c55e; }
.score-item .score-value.medium { color: #f59e0b; }
.score-item .score-value.high { color: #ef4444; }

.factors-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.factors-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.factors-list li:last-child {
    border-bottom: none;
}

.factors-list li.positive { color: #22c55e; }
.factors-list li.negative { color: #ef4444; }

/* ==================== DATA FIELDS SECTION ==================== */

.data-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    flex-wrap: wrap;
}

.data-tab {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
    border-radius: 4px 4px 0 0;
    transition: all 0.2s;
}

.data-tab:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.data-tab.active {
    color: var(--accent-blue);
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--accent-blue);
    margin-bottom: -0.5rem;
}

.data-content {
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table tr {
    border-bottom: 1px solid var(--border-color);
}

.data-table tr:last-child {
    border-bottom: none;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: none;
}

.data-table td:first-child {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.875rem;
    color: var(--text-secondary);
    width: 40%;
}

.data-table td:last-child {
    color: var(--text-primary);
    font-weight: 500;
}

/* ==================== TIMELINE PROGRESS (Profile 360) ==================== */

.timeline-progress {
    display: flex;
    justify-content: space-between;
    position: relative;
    padding: 1rem 0;
    margin-bottom: 1rem;
}

.timeline-progress::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 3px;
    background: #374151;
    transform: translateY(-50%);
}

.timeline-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
    flex: 1;
}

.timeline-step .step-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    background: var(--bg-card);
    border: 3px solid #374151;
}

.timeline-step.completed .step-icon {
    background: #22c55e;
    border-color: #22c55e;
    color: white;
}

.timeline-step.current .step-icon {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

.timeline-step .step-label {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
}

.timeline-step .step-date {
    font-size: 0.625rem;
    color: #6b7280;
}

.timeline-actions {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

/* ==================== CARD WITH ICON ==================== */

.card-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.card-content {
    flex: 1;
}

.card-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.card-alert {
    border-left: 4px solid var(--danger);
}

/* ==================== RESPONSIVE ADDITIONS ==================== */

@media (max-width: 768px) {
    .classification-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    .timeline-visual {
        flex-direction: column;
        gap: 1rem;
    }
    
    .timeline-visual::before {
        display: none;
    }
    
    .phase-arrow {
        transform: rotate(90deg);
    }
    
    .accordion-detail {
        grid-template-columns: 1fr;
    }
    
    .scoring-breakdown {
        grid-template-columns: 1fr;
    }
    
    .timeline-progress {
        flex-direction: column;
        gap: 1rem;
    }
    
    .timeline-progress::before {
        display: none;
    }
    
    .timeline-step {
        flex-direction: row;
        gap: 1rem;
    }
}
