* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    max-width: 840px;
    margin: 0 auto;
    padding: 2rem 1rem;
    color: #1a1a1a;
    background: #fafafa;
}
h1 { font-size: 1.5rem; margin-bottom: 2rem; }
.section-label { font-weight: 600; margin-bottom: 0.75rem; font-size: 0.95rem; }

/* Pair rows */
.pair-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: center;
}
.pair-row input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.15s;
}
.pair-row input:focus { outline: none; border-color: #A51C30; }

.pair-mode {
    width: 72px;
    padding: 0.5rem 0.2rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.8rem;
    color: #555;
    background: white;
    text-align: center;
    flex-shrink: 0;
    cursor: pointer;
    transition: border-color 0.15s;
    -webkit-appearance: none;
    appearance: none;
}
.pair-mode:focus { outline: none; border-color: #A51C30; }
.pair-mode:hover { border-color: #999; }

.remove-btn {
    background: none;
    border: none;
    color: #ccc;
    cursor: pointer;
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
    transition: color 0.15s;
}
.remove-btn:hover { color: #c00; }

/* Default mode bar */
.default-mode-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.6rem 0.75rem;
    background: #f0f0f0;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #555;
}
.default-mode-bar label {
    font-weight: 500;
    white-space: nowrap;
}
.mode-pills {
    display: flex;
    gap: 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
}
.mode-pill {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    border: none;
    background: white;
    color: #666;
    cursor: pointer;
    transition: all 0.15s;
    border-right: 1px solid #ddd;
}
.mode-pill:last-child { border-right: none; }
.mode-pill.active {
    background: #A51C30;
    color: white;
}
.mode-pill:not(.active):hover { background: #f5f5f5; }

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}
.btn-link {
    background: none;
    color: #A51C30;
    padding: 0.25rem 0;
    font-size: 0.85rem;
    cursor: pointer;
    border: none;
}
.btn-link:hover { text-decoration: underline; }
.btn-primary {
    background: #A51C30;
    color: white;
    font-weight: 600;
    padding: 0.6rem 2rem;
}
.btn-primary:hover { background: #8c1728; }
.btn-primary:disabled { background: #ccc; cursor: not-allowed; }
.btn-secondary {
    background: #e8e8e8;
    color: #333;
}
.btn-secondary:hover { background: #ddd; }

/* Controls row */
.controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.25rem;
    margin-bottom: 1.5rem;
}

/* CSV upload */
.csv-section {
    border-top: 1px solid #e0e0e0;
    padding-top: 1rem;
    margin-top: 0.5rem;
    margin-bottom: 2rem;
}
.csv-section label {
    color: #666;
    font-size: 0.85rem;
}
.csv-hint { color: #999; font-size: 0.8rem; margin-top: 0.25rem; }

/* Results */
.results-section { margin-top: 2rem; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}
th {
    text-align: left;
    padding: 0.6rem 0.5rem;
    border-bottom: 2px solid #ddd;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #666;
}
td {
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid #eee;
}
tr:hover td { background: #f5f5f5; }
.error-cell { color: #c00; }

.export-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ccc;
    border-top-color: #A51C30;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 0.5rem;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.status { margin-top: 1rem; font-size: 0.9rem; color: #666; }

/* Autocomplete */
.input-wrap { position: relative; flex: 1; }
.input-wrap input { width: 100%; }
.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    z-index: 10;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}
.suggestions.active { display: block; }
.suggestion-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 1px solid #f5f5f5;
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover, .suggestion-item.selected {
    background: #f5f0f0;
}

/* Map button in results */
.map-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    padding: 0.2rem 0.35rem;
    line-height: 0;
    color: #666;
    transition: all 0.15s;
}
.map-btn svg { display: block; }
.map-btn:hover { border-color: #A51C30; color: #A51C30; }

/* Map modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-backdrop.active { display: flex; }
.modal {
    background: white;
    border-radius: 8px;
    width: min(900px, 95vw);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #eee;
}
.modal-title { font-size: 0.95rem; font-weight: 600; }
.modal-meta { font-size: 0.8rem; color: #666; margin-top: 0.15rem; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    line-height: 1;
}
.modal-close:hover { color: #333; }
#map { height: 500px; width: 100%; }
@media (max-width: 600px) {
    #map { height: 400px; }
}
