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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

.controls {
    display: flex;
    gap: 15px;
    padding: 20px 30px;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-active {
    background: #667eea;
    color: white;
}

#searchInput {
    flex: 1;
    min-width: 250px;
    padding: 12px 20px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

#searchInput:focus {
    outline: none;
    border-color: #667eea;
}

.table-filters {
    display: flex;
    gap: 15px;
    padding: 15px 30px;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
    flex-wrap: wrap;
}

.table-filters select {
    padding: 10px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
    min-width: 180px;
}

.table-filters select:focus {
    outline: none;
    border-color: #667eea;
}

.table-filters select:hover {
    border-color: #667eea;
}

.view-container {
    padding: 30px;
    min-height: 600px;
}

#map {
    width: 100%;
    height: 600px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.legend {
    margin-top: 20px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.legend h3 {
    margin-bottom: 10px;
    color: #333;
}

.legend-item {
    display: flex;
    align-items: center;
    margin: 8px 0;
    gap: 10px;
}

.marker-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.marker-indicator.high {
    background: #28a745;
}

.marker-indicator.medium {
    background: #ffc107;
}

.marker-indicator.low {
    background: #dc3545;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

thead {
    background: #667eea;
    color: white;
}

th, td {
    padding: 15px;
    text-align: left;
}

th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.9em;
    letter-spacing: 0.5px;
}

th[data-sort] {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: all 0.2s ease;
}

th[data-sort]:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

th[data-sort].sort-asc,
th[data-sort].sort-desc {
    background: #5568d3;
}

.sort-arrow {
    font-size: 0.8em;
    margin-left: 5px;
}

tbody tr {
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

tbody tr:hover {
    background-color: #f8f9fa;
}

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

.rating {
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 5px;
    display: inline-block;
}

.rating.high {
    background: #d4edda;
    color: #155724;
}

.rating.medium {
    background: #fff3cd;
    color: #856404;
}

.rating.low {
    background: #f8d7da;
    color: #721c24;
}

.key-phrases {
    font-size: 0.9em;
    color: #666;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.3s;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close:hover,
.close:focus {
    color: #000;
}

.location-details {
    margin-top: 20px;
}

.detail-section {
    margin: 20px 0;
}

.detail-section h3 {
    color: #667eea;
    margin-bottom: 10px;
}

.phrase-list {
    list-style: none;
    padding: 0;
}

.phrase-list li {
    padding: 8px 12px;
    margin: 5px 0;
    background: #f8f9fa;
    border-left: 3px solid #667eea;
    border-radius: 4px;
}

footer {
    background: #f8f9fa;
    padding: 20px 30px;
    text-align: center;
    color: #666;
    border-top: 2px solid #e9ecef;
}

footer p {
    margin: 5px 0;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }

    .controls {
        flex-direction: column;
    }

    #searchInput {
        width: 100%;
    }

    /* Make table scrollable horizontally on mobile */
    #tableView {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        font-size: 0.85em;
        min-width: 800px; /* Ensures table doesn't compress too much */
    }

    th, td {
        padding: 10px 8px;
        white-space: nowrap;
    }

    /* Hide key phrases column on mobile to save space */
    .key-phrases {
        display: none;
    }

    th:last-child {
        display: none;
    }

    /* Make filters stack vertically on mobile */
    .table-filters {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .table-filters select,
    .table-filters button {
        width: 100%;
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 20px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5em;
    }

    .subtitle {
        font-size: 0.9em;
    }

    table {
        font-size: 0.75em;
    }

    th, td {
        padding: 8px 5px;
    }

    /* Further reduce table columns on very small screens */
    td:nth-child(2), /* Address column */
    th:nth-child(2) {
        display: none;
    }
}
