* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

.crime-tool-container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.tool-header {
    background: linear-gradient(135deg, #b00000 0%, #d80000 100%);
    color: white;
    padding: 40px 30px;
    text-align: center;
}

.tool-header h2 {
    font-size: 2rem;
    margin-bottom: 10px;
    font-weight: 700;
    color: #FFF;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin: 0;
}

.search-section {
    padding: 40px 30px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.video-embed {
    float: right;
    width: 35%;
    margin: 0 0 20px 25px;
    position: relative;
    padding-bottom: 19.69%;
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.video-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
}

.data-source {
    font-size: 0.85rem;
    font-style: italic;
    color: #666;
    margin-top: 15px;
}

.data-source a {
    color: #d80000;
    text-decoration: none;
}

.data-source a:hover {
    text-decoration: underline;
}

.input-group {
    display: flex;
    gap: 15px;
    max-width: 600px;
    margin: 0 auto;
}

#postcode-input {
    flex: 1;
    padding: 15px 20px;
    font-size: 1rem;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    transition: all 0.3s ease;
}

#postcode-input:focus {
    outline: none;
    border-color: #d80000;
    box-shadow: 0 0 0 3px rgba(216, 0, 0, 0.1);
}

.btn-primary {
    background: #d80000;
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    min-width: 180px;
}

.btn-primary:hover {
    background: #a00000;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(216, 0, 0, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #ffffff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-screen {
    padding: 60px 30px;
    text-align: center;
}

.loading-content {
    max-width: 500px;
    margin: 0 auto;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #e5e7eb;
    border-top-color: #d80000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.loading-content h3 {
    color: #b00000;
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.loading-content p {
    color: #6b7280;
    margin-bottom: 30px;
}

.progress-bar {
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #d80000, #ff0000);
    animation: progress 2s ease-in-out infinite;
}

@keyframes progress {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

.results-section {
    padding: 40px 30px;
}

.location-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e5e7eb;
}

.location-header h3 {
    color: #b00000;
    font-size: 1.8rem;
    margin-bottom: 5px;
}

.location-meta {
    color: #6b7280;
    font-size: 1rem;
}

.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: linear-gradient(135deg, #fff5f5 0%, #ffe5e5 100%);
    border: 2px solid #ffcccc;
    border-radius: 12px;
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(216, 0, 0, 0.15);
}

.stat-card.total-crimes {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border-color: #fecaca;
}

.stat-icon {
    font-size: 4rem;
    line-height: 1;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.9rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #b00000;
    margin: 5px 0;
}

.stat-period {
    font-size: 0.85rem;
    color: #9ca3af;
}

.map-container {
    margin-bottom: 40px;
}

.map-container h4 {
    color: #b00000;
    font-size: 1.3rem;
    margin-bottom: 15px;
}

.map-wrapper {
    position: relative;
}

#map {
    height: 500px;
    width: 100%;
    border-radius: 12px;
    border: 2px solid #e5e7eb;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 10px;
}

.map-legend-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 220px;
    max-width: 280px;
    max-height: 450px;
    overflow-y: auto;
    z-index: 1000;
}

.map-legend-overlay h5 {
    color: #b00000;
    font-size: 0.95rem;
    margin-bottom: 12px;
    font-weight: 600;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin-bottom: 4px;
    font-size: 0.85rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
    border: 1px solid #e5e7eb;
}

.legend-item:hover {
    background: #f9fafb;
    border-color: #d80000;
    transform: translateX(-3px);
}

.legend-item.active {
    background: #fff5f5;
    border-color: #d80000;
}

.legend-item.inactive {
    opacity: 0.4;
    background: #f3f4f6;
}

.legend-item.inactive:hover {
    opacity: 0.6;
}

.legend-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    flex-shrink: 0;
    background: white;
    transition: all 0.2s ease;
}

.legend-item.active .legend-toggle {
    background: #d80000;
    border-color: #d80000;
}

.legend-item.active .legend-toggle::after {
    content: '✓';
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
}

.legend-color {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.legend-label {
    flex: 1;
    color: #4b5563;
    font-weight: 500;
}

.legend-count {
    color: #9ca3af;
    font-weight: 600;
    font-size: 0.8rem;
}

.custom-marker {
    background: none;
    border: none;
}

.map-note {
    color: #6b7280;
    font-size: 0.9rem;
    font-style: italic;
    text-align: center;
    margin-bottom: 15px;
}

.facebook-share-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: #1877F2;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    margin: 15px auto 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.facebook-share-btn:hover {
    background-color: #166FE5;
}

.facebook-share-btn:active {
    transform: scale(0.98);
}

.facebook-share-btn svg {
    flex-shrink: 0;
}

.statistics-table {
    margin-bottom: 40px;
}

.statistics-table h4 {
    color: #b00000;
    font-size: 1.3rem;
    margin-bottom: 15px;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    border: 2px solid #e5e7eb;
}

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

thead {
    background: linear-gradient(135deg, #b00000 0%, #d80000 100%);
    color: white;
}

th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 0.95rem;
}

tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: background 0.2s ease;
}

tbody tr:hover {
    background: #f9fafb;
}

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

td {
    padding: 15px;
    font-size: 0.95rem;
}

td:first-child {
    font-weight: 500;
    color: #b00000;
    text-transform: capitalize;
    display: flex;
    align-items: center;
    gap: 10px;
}

.category-indicator {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.percentage-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bar-container {
    flex: 1;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #d80000, #ff0000);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.percentage-text {
    min-width: 50px;
    text-align: right;
    font-weight: 600;
    color: #6b7280;
}

.cta-section {
    background: linear-gradient(135deg, #b00000 0%, #d80000 100%);
    padding: 40px 30px;
    border-radius: 12px;
    margin-top: 20px;
}

.cta-content {
    display: flex;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.cta-icon {
    font-size: 5rem;
    line-height: 1;
}

.cta-text {
    flex: 1;
    min-width: 300px;
    color: white;
}

.cta-text h3 {
    font-size: 1.8rem;
    margin-bottom: 10px;
    color: #FFF;
}

.cta-text p {
    font-size: 1.1rem;
    opacity: 0.95;
    line-height: 1.6;
}

.cta-button {
    background: white;
    color: #d80000;
    padding: 18px 40px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    display: inline-block;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cta-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    background: #fff5f5;
}

.error-message {
    padding: 20px 30px;
    margin: 20px 30px;
    background: #fef2f2;
    border: 2px solid #fecaca;
    border-radius: 8px;
}

.error-content {
    display: flex;
    align-items: center;
    gap: 15px;
    color: #991b1b;
}

.error-icon {
    font-size: 1.5rem;
}

.error-text {
    font-weight: 500;
}

.more-videos-section {
    padding: 30px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

.more-videos-section h4 {
    font-size: 1.3rem;
    color: #333;
    margin-bottom: 20px;
    text-align: center;
}

.videos-grid {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.video-item {
    flex: 1;
    max-width: 48%;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    aspect-ratio: 16 / 9;
}

.video-item iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
}

@media (max-width: 768px) {
    .tool-header h2 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .input-group {
        flex-direction: column;
    }

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

    .map-legend-overlay {
        position: static;
        max-width: 100%;
        margin-bottom: 15px;
        max-height: 250px;
    }

    .cta-content {
        flex-direction: column;
        text-align: center;
    }

    .cta-text {
        min-width: auto;
    }

    .cta-text h3 {
        font-size: 1.5rem;
    }

    th, td {
        padding: 10px;
        font-size: 0.85rem;
    }

    .video-embed {
        float: none;
        width: 100%;
        margin: 0 0 20px 0;
        padding-bottom: 56.25%;
    }

    .videos-grid {
        flex-direction: column;
    }

    .video-item {
        max-width: 100%;
    }
}
