/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
header {
    background-color: #14287b;
    color: white;
    padding: 30px 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
}

header h1 {
    font-size: 28px;
    font-weight: 700;
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.card h2 {
    color: #2c3e50;
    font-size: 20px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #14287b;
}

/* Filters */
.filters-card {
    position: sticky;
    top: 10px;
    z-index: 100;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 13px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group input,
.filter-group select {
    padding: 10px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: #14287b;
}

.filter-actions {
    justify-content: flex-end;
}

/* Stats */
.stats-card {
    background: linear-gradient(135deg, #14287b 0%, #0f1e5c 100%);
    color: white;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    text-align: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
}

.stat-label {
    font-size: 14px;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Contractors grid */
.contractors-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Contractor card */
.contractor-card {
    background: #f8f9fa;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.contractor-card:hover {
    border-color: #14287b;
    box-shadow: 0 4px 12px rgba(20, 40, 123, 0.15);
}

.contractor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    cursor: pointer;
    user-select: none;
}

.contractor-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.contractor-name {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
}

.contractor-meta {
    display: flex;
    gap: 15px;
    font-size: 13px;
    color: #6c757d;
}

.contractor-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.contractor-stats {
    display: flex;
    align-items: center;
    gap: 20px;
}

.leads-count {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #14287b;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    min-width: 80px;
}

.leads-count .count {
    font-size: 24px;
    font-weight: 700;
}

.leads-count .label {
    font-size: 11px;
    text-transform: uppercase;
    opacity: 0.9;
}

.source-breakdown {
    display: flex;
    gap: 10px;
}

.source-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 15px;
    border-radius: 6px;
    font-size: 12px;
    min-width: 50px;
}

.source-badge.dp {
    background: #e3f2fd;
    color: #1565c0;
}

.source-badge.bp {
    background: #fff3e0;
    color: #e65100;
}

.source-badge.other {
    background: #f3e5f5;
    color: #7b1fa2;
}

.source-badge .count {
    font-size: 18px;
    font-weight: 700;
}

.expand-icon {
    font-size: 20px;
    color: #6c757d;
    transition: transform 0.2s;
}

.contractor-card.expanded .expand-icon {
    transform: rotate(180deg);
}

/* Leads details */
.leads-details {
    display: none;
    background: white;
    border-top: 1px solid #e9ecef;
}

.contractor-card.expanded .leads-details {
    display: block;
}

.leads-table {
    width: 100%;
    padding: 15px;
}

.lead-row {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr 1fr 1fr 1fr;
    gap: 15px;
    padding: 12px 15px;
    border-bottom: 1px solid #e9ecef;
    font-size: 14px;
    align-items: center;
}

.lead-row:last-child {
    border-bottom: none;
}

.lead-row.header {
    background: #f8f9fa;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
    border-radius: 8px;
}

.lead-row .contact-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.lead-row .contact-name {
    font-weight: 600;
    color: #2c3e50;
}

.lead-row .contact-email {
    font-size: 12px;
    color: #6c757d;
}

.lead-row .offer-total {
    font-weight: 600;
    color: #14287b;
}

.lead-row .lead-date {
    color: #6c757d;
    font-size: 13px;
}

.source-tag {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.source-tag.dp {
    background: #e3f2fd;
    color: #1565c0;
}

.source-tag.bp {
    background: #fff3e0;
    color: #e65100;
}

.channel-tag {
    font-size: 12px;
    color: #495057;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Buttons */
.btn-primary {
    background: #14287b;
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
    background: #0f1e5c;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Loading state */
.loading {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #14287b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    color: #666;
    font-size: 16px;
}

/* Error state */
.error {
    text-align: center;
    padding: 40px 20px;
}

.error-content {
    background: #f8d7da;
    color: #721c24;
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    margin: 0 auto;
}

.error-content h2 {
    margin-bottom: 15px;
    border-bottom: none;
}

.error-content button {
    background: #14287b;
    color: white;
    border: none;
    padding: 10px 25px;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 15px;
}

/* No data */
.no-data {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

.no-data p {
    font-size: 16px;
}

/* Hidden class */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 1024px) {
    .lead-row {
        grid-template-columns: 1.5fr 1fr 1fr 1fr;
    }

    .lead-row .contact-phone,
    .lead-row .address {
        display: none;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header {
        padding: 20px 15px;
    }

    header h1 {
        font-size: 22px;
    }

    .card {
        padding: 15px;
    }

    .filters-card {
        position: static;
    }

    .filters-grid {
        grid-template-columns: 1fr 1fr;
    }

    .contractor-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .contractor-stats {
        width: 100%;
        justify-content: space-between;
    }

    .lead-row {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .lead-row.header {
        display: none;
    }

    .lead-row .offer-total,
    .lead-row .lead-date {
        text-align: right;
    }

    .source-breakdown {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .filters-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .stat-value {
        font-size: 28px;
    }

    .leads-count {
        padding: 8px 15px;
    }

    .leads-count .count {
        font-size: 20px;
    }
}
