/* Search page specific styles */

.search-page {
    height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --panel-bg: var(--bg-warm);
    --panel-card-bg: var(--surface);
    --panel-border: var(--border);
    --panel-shadow: 0 10px 24px var(--shadow-warm);
    --panel-accent: var(--primary);
    --panel-muted: var(--text-secondary);
}

/* ========================================
   Direction Bar (unified search + location)
   ======================================== */

.direction-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    min-height: var(--direction-bar-height);
    flex-shrink: 0;
    flex-wrap: wrap;
    z-index: 95;
    overflow: visible;
}

.direction-search {
    display: flex;
    align-items: center;
    gap: 0;
    flex: 0 1 380px;
    min-width: 180px;
    background: var(--bg-warm);
    border: 1.5px solid transparent;
    border-radius: var(--radius-full);
    padding: 0 5px 0 14px;
    transition: all 0.2s ease;
}

.direction-search:focus-within {
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(143, 176, 122, 0.1);
}

.direction-search-icon {
    flex-shrink: 0;
    color: var(--text-muted);
    opacity: 0.6;
    transition: all var(--transition-fast);
}

.direction-search:focus-within .direction-search-icon {
    color: var(--primary);
    opacity: 1;
}

.direction-input {
    flex: 1;
    padding: 7px 10px;
    border: none;
    background: transparent;
    font-size: 0.86rem;
    font-family: inherit;
    color: var(--text-primary);
    outline: none;
    min-width: 0;
}

.direction-input::placeholder {
    color: var(--text-muted);
    font-size: 0.84rem;
}

.direction-search-btn {
    padding: 6px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
    letter-spacing: 0.01em;
}

.direction-search-btn:hover {
    background: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(45, 90, 61, 0.25);
}

.direction-search-btn:active {
    transform: scale(0.97);
}

.direction-search-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

/* Autocomplete suggestions */
.direction-search,
.search-form-mobile {
    position: relative;
}

.autocomplete-suggestions {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin: 4px 0 0;
    padding: 4px 0;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    z-index: 200;
    max-height: 260px;
    overflow-y: auto;
}

.autocomplete-suggestions.visible {
    display: block;
}

.autocomplete-suggestion {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 8px 14px;
    cursor: pointer;
    transition: background 0.1s;
}

.autocomplete-suggestion:hover,
.autocomplete-suggestion.active {
    background: var(--bg-warm);
}

.autocomplete-label {
    font-size: 0.84rem;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.autocomplete-secondary {
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
    white-space: nowrap;
}

/* Vertical divider between search and results */
.direction-divider {
    width: 1px;
    height: 22px;
    background: var(--border);
    flex-shrink: 0;
    opacity: 0.6;
}

.direction-divider.hidden {
    display: none;
}

/* Direction info (location result) */
.direction-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.direction-info.hidden {
    display: none;
}

.direction-info.animate-in {
    animation: directionInfoReveal 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes directionInfoReveal {
    from {
        opacity: 0;
        transform: translateX(10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.direction-location {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
}

.direction-address {
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--text-secondary);
    line-height: 1.3;
}

.direction-tags {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.direction-tag {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 3px 10px;
    background: var(--bg-warm);
    border: none;
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    white-space: nowrap;
    opacity: 0;
    transform: translateY(3px);
    animation: tagSlideIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    letter-spacing: 0.01em;
}

.direction-tag:nth-child(1) { animation-delay: 0.06s; }
.direction-tag:nth-child(2) { animation-delay: 0.13s; }
.direction-tag:nth-child(3) { animation-delay: 0.2s; }

.direction-tag.highlight {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.direction-tag.subtle {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.66rem;
    font-variant-numeric: tabular-nums;
}

@keyframes tagSlideIn {
    from {
        opacity: 0;
        transform: translateY(3px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.search-page .search-panel h2,
.search-page .metric-name,
.search-page .direction-address {
    font-family: 'Sora', 'DM Sans', sans-serif;
}

/* Main layout */
.search-main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Left panel */
.search-panel {
    width: 480px;
    background: linear-gradient(180deg, var(--bg-cream) 0%, var(--bg-warm) 100%);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    overflow-y: overlay;
    scrollbar-gutter: stable;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px;
}

/* Thin, unobtrusive scrollbar for left panel */
.search-panel::-webkit-scrollbar {
    width: 6px;
}

.search-panel::-webkit-scrollbar-track {
    background: transparent;
}

.search-panel::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.search-panel::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.search-panel > section {
    background: var(--panel-card-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-md);
    padding: 0;
    box-shadow: var(--panel-shadow);
}

/* Tab bar actions (right side) */
.tab-bar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    padding-left: 12px;
    flex-shrink: 0;
}

.tab-bar-action-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.tab-bar-action-btn:hover {
    background: rgba(45, 90, 61, 0.06);
    color: var(--text-primary);
}

.tab-bar-action-btn:active {
    transform: scale(0.97);
}

.tab-bar-action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tab-bar-action-btn:disabled:hover {
    background: transparent;
    color: var(--text-muted);
}

.tab-bar-action-btn.hidden {
    display: none;
}

/* Legacy support */
.tab-bar-report-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    margin-left: 8px;
    background: var(--accent);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(143, 176, 122, 0.3);
}

.tab-bar-report-btn:hover {
    background: #7A9D66;
}

.tab-bar-report-btn:active {
    transform: translateY(1px);
}

.tab-bar-report-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

.tab-bar-report-btn.hidden {
    display: none;
}

/* Direction bar status messages */
.direction-bar .search-status,
.direction-bar .report-status {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-left: auto;
    flex-shrink: 0;
}

.direction-bar .search-status.error,
.direction-bar .report-status.error {
    color: var(--error);
}

.direction-bar .report-status.success {
    color: var(--success);
}

.direction-bar .search-status.loading {
    display: flex;
    align-items: center;
    gap: 6px;
}

.direction-bar .search-status.loading::before {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Legacy location-strip (kept for any remaining references) */
.location-strip { display: none; }
.location-strip.hidden { display: none; }

.search-status {
    font-size: 0.82rem;
    color: var(--panel-muted);
    min-height: 20px;
    padding: 4px 0;
}

.search-status.error {
    color: var(--error);
}

.search-status.loading {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-status.loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Floating map legend overlay */
.map-legend {
    position: absolute;
    bottom: 28px;
    left: 12px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    max-width: 220px;
    font-size: 0.78rem;
    transition: box-shadow 0.2s;
}

.map-legend:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
}

.map-legend-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
    gap: 6px;
}

.map-legend-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.map-legend-chevron {
    transition: transform 0.25s ease;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.map-legend.is-collapsed .map-legend-chevron {
    transform: rotate(-90deg);
}

.map-legend-body {
    padding: 0 12px 10px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.25s ease, padding 0.3s ease;
    max-height: 400px;
    opacity: 1;
}

.map-legend.is-collapsed .map-legend-body {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.map-legend .legend-item {
    gap: 8px;
    font-size: 0.78rem;
}

.map-legend .legend-color {
    width: 20px;
    height: 12px;
    border-radius: 2px;
}

/* Noise contour toggle */
.noise-contour-toggle {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
}

.noise-contour-toggle .checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.82rem;
}

.noise-contour-toggle .data-granularity {
    font-size: 0.72rem;
    color: var(--panel-muted);
}

/* Results sections */
.results-section {
    padding: 18px;
}

.results-section.hidden {
    display: none;
}


/* Report status (used in location strip) */
.report-status {
    min-height: 0;
    font-size: 0.85rem;
    color: var(--panel-muted);
}

.report-status:empty {
    display: none;
}

.report-status.success {
    color: var(--success);
}

.report-status.error {
    color: var(--error);
}

.report-status.loading {
    color: var(--panel-muted);
}

/* Metrics container */
.metrics-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

/* Full-width metric cards (Demografia, Clima, Inundacion) */
.metric-card-full {
    grid-column: 1 / -1;
}

/* Metric cards */
.metric-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 16px;
    border: 1px solid var(--border);
    border-top: 3px solid var(--metric-accent, var(--primary));
    transition: box-shadow 0.2s, transform 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    gap: 6px;
    opacity: 0;
    transform: translateY(6px);
    animation: cardReveal 0.5s ease forwards;
}

.metric-card:hover {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.metric-card:nth-child(1) { animation-delay: 0.02s; }
.metric-card:nth-child(2) { animation-delay: 0.04s; }
.metric-card:nth-child(3) { animation-delay: 0.06s; }
.metric-card:nth-child(4) { animation-delay: 0.08s; }
.metric-card:nth-child(5) { animation-delay: 0.1s; }
.metric-card:nth-child(6) { animation-delay: 0.12s; }
.metric-card:nth-child(7) { animation-delay: 0.14s; }
.metric-card:nth-child(8) { animation-delay: 0.16s; }

@keyframes cardReveal {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes barGrow {
    from {
        transform: scaleX(0);
    }
    to {
        transform: scaleX(1);
    }
}

.metric-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.metric-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Info tooltip icon */
.metric-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: help;
    position: relative;
    vertical-align: middle;
}
.metric-info:hover {
    color: var(--primary);
}
.metric-info:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 0;
    bottom: calc(100% + 6px);
    transform: translateX(-10px);
    background: var(--text-primary, #1e293b);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 400;
    font-style: normal;
    line-height: 1.4;
    padding: 8px 12px;
    border-radius: 8px;
    white-space: normal;
    width: max-content;
    max-width: 260px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    pointer-events: none;
}
.metric-info:hover::before {
    content: '';
    position: absolute;
    left: 4px;
    bottom: calc(100% + 2px);
    border: 5px solid transparent;
    border-top-color: var(--text-primary, #1e293b);
    z-index: 100;
    pointer-events: none;
}

.metric-granularity {
    font-size: 0.72rem;
    color: var(--text-secondary);
    padding: 3px 8px;
    background: var(--surface-warm);
    border-radius: 999px;
    border: 1px solid var(--border-light);
}

.metric-value-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.metric-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
}

.metric-value.no-data {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 400;
}

.metric-chip {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
    line-height: 1.4;
    position: relative;
    cursor: default;
}

.metric-chip[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 6px);
    transform: translateX(-50%);
    background: var(--text-primary, #1e293b);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 400;
    padding: 5px 10px;
    border-radius: 6px;
    white-space: nowrap;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    pointer-events: none;
}

.metric-chip[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: calc(100% + 2px);
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--text-primary, #1e293b);
    z-index: 100;
    pointer-events: none;
}

.metric-chip-excepcional {
    background: #d1fae5;
    color: #065f46;
}

.metric-chip-muybuena {
    background: #dcfce7;
    color: #166534;
}

.metric-chip-buena {
    background: #ecfccb;
    color: #3f6212;
}

.metric-chip-encima {
    background: #fef9c3;
    color: #713f12;
}

.metric-chip-media {
    background: #fef3c7;
    color: #92400e;
}

.metric-chip-debajo {
    background: #ffedd5;
    color: #9a3412;
}

.metric-chip-baja {
    background: #fee2e2;
    color: #991b1b;
}

.metric-chip-muybaja {
    background: #fecaca;
    color: #7f1d1d;
}

.metric-chip-atencion {
    background: #fca5a5;
    color: #450a0a;
}

.metric-chip-info {
    background: #f1f5f9;
    color: #475569;
}

.metric-chip-loading {
    background: #f1f5f9;
    color: #94a3b8;
}

.metric-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.metric-bar {
    height: 4px;
    background: var(--accent-muted);
    border-radius: 2px;
    margin-top: 10px;
    overflow: hidden;
}

.metric-bar-fill {
    height: 100%;
    border-radius: 2px;
    transform-origin: left;
    animation: barGrow 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Detail breakdown rows inside metric cards */
.metric-detail {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.metric-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.metric-detail-label {
    color: var(--text-secondary);
}

.metric-detail-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* Comparativa component */
.comparativa {
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--surface-warm);
    border-radius: var(--radius-md);
}

.comparativa-header {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-style: italic;
}

.comparativa-toggle {
    display: flex;
    background: var(--bg-primary, #fff);
    border-radius: var(--radius-sm);
    padding: 2px;
    gap: 2px;
    margin-bottom: 10px;
    border: 1px solid var(--border-light, #e5e7eb);
}

.comparativa-btn {
    flex: 1;
    padding: 5px 8px;
    font-size: 0.75rem;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.comparativa-btn:hover {
    background: var(--surface-warm);
}

.comparativa-btn.active {
    background: var(--text-primary, #1e293b);
    color: #fff;
    font-weight: 600;
}

.comparativa-body {
    min-height: 40px;
}

.comparativa-nodata {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
    padding: 4px 0;
}

.comparativa-tips {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--border-light, #e5e7eb);
}

.comparativa-tip {
    margin: 0;
    padding: 2px 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.comparativa-tip strong {
    color: var(--text-primary);
}

/* Compare modal */
.compare-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.compare-modal.hidden { display: none; }

.compare-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.45);
}

.compare-modal-card {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    width: 90vw;
    max-width: 780px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.compare-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.compare-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
}
.compare-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0 4px;
}

.compare-modal-body {
    padding: 16px 20px;
    overflow-y: auto;
}

.compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.compare-table th {
    text-align: left;
    padding: 8px 10px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.compare-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
}
.compare-metric-name {
    font-weight: 500;
    white-space: nowrap;
}
.compare-section-val {
    font-weight: 700;
    color: var(--primary);
}
.compare-section-val.no-data {
    color: var(--text-secondary);
    font-weight: 400;
}

.compare-pctl {
    display: flex;
    align-items: center;
    gap: 6px;
}
.compare-pctl-bar {
    width: 50px;
    height: 6px;
    background: var(--surface-warm);
    border-radius: 3px;
    overflow: hidden;
}
.compare-pctl-fill {
    height: 100%;
    border-radius: 3px;
}
.compare-pctl span {
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

@media (max-width: 700px) {
    .compare-modal-card {
        width: 96vw;
        max-height: 90vh;
        border-radius: 12px;
    }
    .compare-table { font-size: 0.75rem; }
    .compare-table th,
    .compare-table td { padding: 6px 5px; }
    .compare-pctl-bar { width: 32px; }
}

/* Report document (PDF) */
.report-print-root {
    position: absolute;
    left: -12000px;
    top: 0;
    width: 794px;
    background: #ffffff;
    opacity: 1;
    pointer-events: none;
    z-index: 9999;
}

.report-document {
    width: 700px;
    max-width: 100%;
    padding: 28px 28px;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #2C3319;
    background: #ffffff;
}

.report-document,
.report-document * {
    box-sizing: border-box;
}

.report-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 10px;
}

.report-title {
    font-family: 'Sora', 'DM Sans', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: #2D5A3D;
}

.report-subtitle {
    margin-top: 6px;
    color: #5C6B4F;
    font-size: 0.95rem;
}

.report-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.report-meta-item {
    background: #FBF9F5;
    border: 1px solid #DED8CA;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.75rem;
    color: #5C6B4F;
}

.report-block {
    margin-top: 18px;
}

.report-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #8A9474;
    margin-bottom: 10px;
    font-weight: 700;
}

.report-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.report-summary-item {
    border: 1px solid #DED8CA;
    border-radius: 12px;
    padding: 10px 12px;
    background: #FBF9F5;
}

.report-summary-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.report-summary-text {
    font-size: 0.82rem;
    color: #5C6B4F;
    word-break: break-word;
}

.report-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.report-chip.good {
    background: #dcfce7;
    color: #166534;
}

.report-chip.neutral {
    background: #fef3c7;
    color: #92400e;
}

.report-chip.bad {
    background: #fee2e2;
    color: #991b1b;
}

.report-chip.info {
    background: #e0f2fe;
    color: #0c4a6e;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    table-layout: fixed;
}

.report-table th {
    text-align: left;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8A9474;
    padding: 8px 6px;
    border-bottom: 1px solid #DED8CA;
    word-break: break-word;
}

.report-table td {
    padding: 8px 6px;
    border-bottom: 1px solid #EAE5DB;
    vertical-align: top;
    word-break: break-word;
}

.report-table .report-value {
    font-weight: 600;
    color: #2C3319;
}

.report-table th:nth-child(1),
.report-table td:nth-child(1) { width: 20%; }
.report-table th:nth-child(2),
.report-table td:nth-child(2) { width: 18%; }
.report-table th:nth-child(3),
.report-table td:nth-child(3) { width: 42%; }
.report-table th:nth-child(4),
.report-table td:nth-child(4) { width: 20%; }

.report-detail-list {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.report-detail-group {
    border: 1px solid #DED8CA;
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: #ffffff;
}

.report-detail-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.78rem;
    color: #5C6B4F;
    align-items: flex-start;
}

.report-detail-label {
    color: #8A9474;
    flex: 1 1 60%;
    min-width: 0;
}

.report-detail-value {
    font-weight: 600;
    color: #2C3319;
    flex: 1 1 40%;
    min-width: 0;
    text-align: right;
    word-break: break-word;
}

/* Map container */
.search-map-container {
    flex: 1;
    position: relative;
}

/* Marker styles */
/* Location marker — clean dot with soft pulse */
.search-marker {
    width: 18px;
    height: 18px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-marker::before {
    content: '';
    position: absolute;
    width: 32px;
    height: 32px;
    background: rgba(45, 90, 61, 0.12);
    border-radius: 50%;
    animation: markerPulse 2.5s ease-out infinite;
}

.search-marker::after {
    content: '';
    width: 14px;
    height: 14px;
    background: var(--primary);
    border: 2.5px solid white;
    border-radius: 50%;
    box-shadow: 0 1px 6px rgba(44, 51, 25, 0.35);
    position: relative;
    z-index: 1;
}

@keyframes markerPulse {
    0% {
        transform: scale(0.8);
        opacity: 0.6;
    }
    70% {
        transform: scale(2.2);
        opacity: 0;
    }
    100% {
        transform: scale(2.2);
        opacity: 0;
    }
}

/* Radar sweep overlay — positioned at marker, sized to ~100m radius */
.radar-sweep-container {
    pointer-events: none;
}

.radar-sweep {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        transparent 0deg,
        rgba(45, 90, 61, 0.25) 10deg,
        rgba(45, 90, 61, 0.12) 30deg,
        transparent 60deg
    );
    animation: radarSweep 2.5s linear infinite;
    opacity: 1;
}

.radar-sweep.done {
    opacity: 0;
    transition: opacity 0.8s ease;
}

@keyframes radarSweep {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* Crime category rows */
.crime-category-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 0;
    font-size: 0.82rem;
}

.crime-category-label {
    color: var(--text-secondary);
}

.crime-category-value {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.crime-category-pct {
    color: #999;
    font-size: 0.75rem;
    font-weight: 400;
}

.crime-source-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    background: var(--surface-warm);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    margin-right: 4px;
}

/* Comparison bar chart (all metrics) */
.comp-bars {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 0 4px;
}

.comp-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.comp-bar-label {
    flex: 0 0 80px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-align: right;
}

.comp-bar-highlight .comp-bar-label {
    font-weight: 600;
    color: var(--text-primary);
}

.comp-bar-track {
    flex: 1;
    height: 18px;
    background: var(--surface-warm);
    border-radius: 4px;
    overflow: hidden;
}

.comp-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: #c0c0c0;
    transform-origin: left;
    animation: barGrow 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.comp-bar-highlight .comp-bar-fill {
    background: var(--metric-accent, #94a3b8);
}

.comp-bar-value {
    flex: 0 0 60px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: right;
}

.comp-bar-highlight .comp-bar-value {
    font-weight: 700;
    color: var(--text-primary);
}

.crime-footer {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
    flex-wrap: wrap;
}

@media (prefers-reduced-motion: reduce) {
    .metric-card {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .metric-card:hover {
        transform: none;
    }

    .metric-bar-fill,
    .overview-bar-fill,
    .overview-score-bar-fill,
    .comp-bar-fill {
        animation: none;
        transform: none;
    }

    .search-btn {
        transition: none;
    }
}

/* Mobile search fallback (hidden on desktop) */
.mobile-search-section {
    display: none;
    padding: 18px;
    background: var(--panel-card-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-md);
    box-shadow: var(--panel-shadow);
}

.search-form-mobile {
    display: flex;
    gap: 8px;
}

.search-form-mobile input {
    flex: 1;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-warm);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-form-mobile input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(143, 176, 122, 0.15);
}

/* Responsive */
@media (max-width: 900px) {
    .search-main {
        flex-direction: column;
    }

    .search-panel {
        width: 100%;
        max-height: 50vh;
    }

    .search-map-container {
        min-height: 50vh;
    }

    .direction-bar {
        display: none;
    }

    .mobile-search-section {
        display: block;
    }

    /* Start collapsed on mobile */
    .map-legend {
        bottom: 8px;
        left: 8px;
        max-width: 180px;
        font-size: 0.72rem;
    }
}

@media (max-width: 600px) {
    .direction-bar {
        display: none;
    }

    .mobile-search-section {
        display: block;
    }

    .search-form-mobile {
        flex-direction: column;
    }

    .search-form-mobile .search-btn {
        justify-content: center;
    }

    .metrics-container {
        grid-template-columns: 1fr;
    }

    .tab-bar-action-btn span {
        display: none;
    }

    .tab-bar-action-btn {
        padding: 6px 10px;
    }

    .tab-bar-report-btn span {
        display: none;
    }

    .tab-bar-report-btn {
        padding: 6px 10px;
    }
}

/* ========================================
   Profile Modal
   ======================================== */

.profile-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-modal.hidden {
    display: none;
}

.profile-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.profile-modal-card {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    width: 420px;
    max-width: 92vw;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px 32px;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.profile-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.profile-modal-step {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.profile-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}

.profile-modal-close:hover {
    color: var(--text-primary);
}

/* Steps */
.profile-step {
    display: none;
}

.profile-step.active {
    display: block;
    animation: stepFadeIn 0.25s ease;
}

@keyframes stepFadeIn {
    from { opacity: 0; transform: translateX(12px); }
    to   { opacity: 1; transform: translateX(0); }
}

.profile-step-title {
    font-family: 'Sora', 'DM Sans', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px;
}

.profile-step-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0 0 18px;
}

/* Pill buttons */
.profile-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.profile-pill {
    padding: 10px 18px;
    border: 1.5px solid var(--border);
    border-radius: 999px;
    background: var(--surface-warm);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.profile-pill:hover {
    border-color: var(--accent);
    background: #f0f5eb;
}

.profile-pill.selected {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(45, 90, 61, 0.25);
}

/* Footer */
.profile-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    gap: 12px;
}

.profile-btn-back {
    padding: 10px 20px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.profile-btn-back:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.profile-btn-back.hidden {
    visibility: hidden;
}

.profile-btn-next {
    padding: 10px 28px;
    background: var(--primary);
    border: none;
    border-radius: 999px;
    color: white;
    font-size: 0.92rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(45, 90, 61, 0.3);
    margin-left: auto;
}

.profile-btn-next:hover {
    background: var(--primary-light);
}

.profile-btn-next:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

/* ========================================
   Overview Card
   ======================================== */

.overview-card {
    background: linear-gradient(135deg, #f0f7ec 0%, var(--surface) 100%);
    border: 1.5px solid var(--accent-muted);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 4px 16px rgba(143, 176, 122, 0.15);
    opacity: 0;
    transform: translateY(6px);
    animation: cardReveal 0.5s ease forwards;
}

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

.overview-title {
    font-family: 'Sora', 'DM Sans', sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.overview-customize-btn {
    padding: 4px 12px;
    background: var(--surface-warm);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.overview-customize-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Score row */
.overview-score-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.overview-score-big {
    font-family: 'Sora', 'DM Sans', sans-serif;
    font-size: 2.4rem;
    font-weight: 700;
    line-height: 1;
}

.overview-score-max {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
}

.overview-score-bar {
    flex: 1;
    min-width: 80px;
    height: 8px;
    background: var(--accent-muted);
    border-radius: 999px;
    overflow: hidden;
}

.overview-score-bar-fill {
    height: 100%;
    border-radius: 999px;
    transform-origin: left;
    animation: barGrow 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.overview-chip-good {
    font-size: 0.78rem;
    font-weight: 600;
    color: #166534;
    background: #dcfce7;
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

.overview-chip-neutral {
    font-size: 0.78rem;
    font-weight: 600;
    color: #92400e;
    background: #fef3c7;
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

.overview-chip-bad {
    font-size: 0.78rem;
    font-weight: 600;
    color: #991b1b;
    background: #fee2e2;
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

.overview-chip-info {
    font-size: 0.78rem;
    font-weight: 600;
    color: #475569;
    background: #f1f5f9;
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

/* Mini-bars */
.overview-bars {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.overview-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
}

.overview-bar-label {
    width: 110px;
    flex-shrink: 0;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.overview-bar-icon {
    font-size: 0.7rem;
    font-weight: 700;
}

.overview-bar-icon.good {
    color: #22c55e;
}

.overview-bar-icon.bad {
    color: #ef4444;
}

.overview-bar-track {
    flex: 1;
    height: 6px;
    background: var(--accent-muted);
    border-radius: 999px;
    overflow: hidden;
}

.overview-bar-fill {
    height: 100%;
    border-radius: 999px;
    transform-origin: left;
    animation: barGrow 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.overview-bar-row:nth-child(1) .overview-bar-fill { animation-delay: 0.05s; }
.overview-bar-row:nth-child(2) .overview-bar-fill { animation-delay: 0.1s; }
.overview-bar-row:nth-child(3) .overview-bar-fill { animation-delay: 0.15s; }
.overview-bar-row:nth-child(4) .overview-bar-fill { animation-delay: 0.2s; }
.overview-bar-row:nth-child(5) .overview-bar-fill { animation-delay: 0.25s; }
.overview-bar-row:nth-child(6) .overview-bar-fill { animation-delay: 0.3s; }

.overview-bar-score {
    width: 28px;
    text-align: right;
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--text-primary);
}

/* Highlights */
.overview-highlights {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
}

.overview-highlight {
    font-size: 0.82rem;
    color: var(--text-secondary);
    padding-left: 8px;
    border-left: 2px solid var(--accent);
}

/* Mobile adjustments for modal and overview */
@media (max-width: 600px) {
    .profile-modal-card {
        padding: 20px 18px;
        border-radius: 16px;
    }

    .profile-step-title {
        font-size: 1.05rem;
    }

    .profile-pill {
        padding: 8px 14px;
        font-size: 0.82rem;
    }

    .overview-score-big {
        font-size: 1.8rem;
    }

    .overview-bar-label {
        width: 85px;
        font-size: 0.75rem;
    }
}

/* Ocio Nocturno heatmap/dots toggle */
.ocio-toggle-container {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 5;
    display: inline-flex;
    gap: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 2px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    height: auto;
    width: auto;
}

.ocio-toggle-btn {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #666;
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1.2;
    white-space: nowrap;
    height: auto;
    flex: none;
}

.ocio-toggle-btn:hover {
    background: #f5f5f5;
    color: #333;
}

.ocio-toggle-btn.active {
    background: var(--accent, #dc2626);
    color: #fff;
}
