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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

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

header {
    text-align: center;
    margin-bottom: 24px;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 4px;
}

header .subtitle {
    color: #666;
    font-size: 1.1rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 0;
}

.tab {
    padding: 12px 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: #666;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
}

.tab:hover {
    color: #333;
}

.tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Controls */
.controls {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-weight: 500;
    color: #555;
}

.filter-group select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
    background: white;
    cursor: pointer;
}

.filter-group select:focus {
    outline: none;
    border-color: #2563eb;
}

/* Stats Panel */
.stats-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    text-align: center;
}

.stat-card.wide {
    min-width: 200px;
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: #1a1a2e;
}

.stat-value.positive {
    color: #16a34a;
}

.stat-value.negative {
    color: #dc2626;
}

/* Map Controls */
.map-controls {
    display: flex;
    gap: 20px;
    padding: 12px 16px;
    background: white;
    border-radius: 8px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.map-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #333;
}

.map-controls input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Map */
#map {
    height: 500px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 1;
}

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

.legend h4 {
    margin-bottom: 12px;
    color: #333;
}

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

.marker-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-block;
}

.marker-icon.target {
    background: #dc2626;
    border: 3px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.marker-icon.over {
    background: #2563eb;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.marker-icon.under {
    background: #f97316;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.marker-icon.cluster {
    background: linear-gradient(135deg, #2563eb 50%, #f97316 50%);
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Heat Map Toggle */
.toggle-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #2563eb;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3);
}

.toggle-label {
    font-weight: 500;
    color: #555;
    cursor: pointer;
    user-select: none;
}

/* Heat Map Legend */
.heat-legend {
    background: white;
    padding: 16px;
    border-radius: 8px;
    margin-top: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: none;
}

.heat-legend.visible {
    display: block;
}

.heat-legend h4 {
    margin-bottom: 12px;
    color: #333;
    font-size: 0.95rem;
}

.heat-gradient {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.heat-gradient-bar {
    height: 20px;
    border-radius: 4px;
    background: linear-gradient(to right,
        #313695,  /* Deep blue - lowest */
        #4575b4,
        #74add1,
        #abd9e9,
        #e0f3f8,
        #ffffbf,  /* Yellow - middle */
        #fee090,
        #fdae61,
        #f46d43,
        #d73027,
        #a50026   /* Deep red - highest */
    );
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.heat-gradient-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #666;
}

.heat-gradient-labels span {
    font-weight: 500;
}

.heat-gradient-labels .low {
    color: #313695;
}

.heat-gradient-labels .mid {
    color: #666;
}

.heat-gradient-labels .high {
    color: #a50026;
}

/* Price Diff Section */
.price-diff-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.chart-container {
    background: white;
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    max-height: 400px;
}

/* Tables */
#data-table,
#price-diff-table {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

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

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    font-size: 0.95rem;
}

tr:hover {
    background: #f8f9fa;
}

.positive-diff {
    color: #16a34a;
    font-weight: 600;
}

.negative-diff {
    color: #dc2626;
    font-weight: 600;
}

/* Custom Leaflet Markers */
.custom-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 11px;
    border-radius: 50%;
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

.target-marker {
    background: #dc2626;
    border: 3px solid white;
}

.comp-marker {
    background: #2563eb;
    border: 2px solid white;
}

/* Popup Styles */
.leaflet-popup-content {
    margin: 12px;
    line-height: 1.5;
}

.popup-title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 8px;
    color: #1a1a2e;
}

.popup-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: #16a34a;
    margin-bottom: 4px;
}

.popup-details {
    color: #666;
    font-size: 0.9rem;
}

.popup-diff {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eee;
    font-weight: 600;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px;
    border-top: 1px solid #eee;
}

.pagination button {
    padding: 8px 16px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

.pagination button:hover:not(:disabled) {
    background: #1d4ed8;
}

.pagination button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.pagination span {
    color: #666;
    font-size: 0.9rem;
}

.table-info {
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    font-size: 0.85rem;
    color: #666;
}

/* Dataset Stats Summary */
.dataset-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e3a5f;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card.highlight {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
}

.stat-card.highlight .stat-value {
    color: white;
    font-size: 1.7rem;
}

.stat-card.highlight .stat-label {
    color: rgba(255,255,255,0.85);
}

@media (max-width: 768px) {
    .dataset-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-card .stat-value {
        font-size: 1.2rem;
    }

    .stat-card .stat-label {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .dataset-stats {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-card .stat-value {
        font-size: 1rem;
    }
}

/* Data Table Controls */
.data-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: white;
    border-radius: 12px 12px 0 0;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
}

.data-search {
    flex: 1;
    max-width: 300px;
}

.data-search input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.data-search input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.data-search input::placeholder {
    color: #999;
}

.data-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.data-actions label {
    font-size: 0.9rem;
    color: #555;
    font-weight: 500;
}

.data-actions select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
}

.data-actions select:focus {
    outline: none;
    border-color: #2563eb;
}

.btn-export {
    padding: 10px 18px;
    background: #16a34a;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-export:hover {
    background: #15803d;
}

/* Sortable Table Headers */
th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

th.sortable:hover {
    background: #e5e7eb;
}

.sort-arrow {
    font-size: 0.7rem;
    margin-left: 4px;
    opacity: 1;
    color: #2563eb;
}

.sort-arrow.inactive {
    opacity: 0.3;
    color: #888;
}

/* Table Wrapper for horizontal scroll */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Target Row Highlight */
tr.target-row {
    background: #fef2f2;
}

tr.target-row:hover {
    background: #fef2f2;
}

/* Summary Row */
.summary-row {
    background: #f0fdf4;
    border-top: 2px solid #22c55e;
}

.summary-row td {
    font-size: 0.9rem;
    color: #166534;
}

.summary-row:hover {
    background: #f0fdf4;
}

tfoot {
    border-top: 2px solid #16a34a;
}

/* Trends Section */
.trends-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.chart-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.chart-card.full-width {
    grid-column: 1 / -1;
}

.chart-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 4px;
}

.chart-card .chart-subtitle {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 16px;
}

.chart-container-trends {
    position: relative;
    height: 280px;
}

.seasonality-container {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.seasonality-chart {
    flex: 1;
    min-width: 0;
}

.seasonality-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    min-width: 320px;
}

.season-stat-card {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 8px;
    border-left: 4px solid;
}

.season-stat-card.winter {
    border-left-color: #3b82f6;
}

.season-stat-card.spring {
    border-left-color: #22c55e;
}

.season-stat-card.summer {
    border-left-color: #f59e0b;
}

.season-stat-card.fall {
    border-left-color: #ef4444;
}

.season-stat-card h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.season-stat-card .stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #555;
    margin-bottom: 4px;
}

.season-stat-card .stat-row:last-child {
    margin-bottom: 0;
}

.season-stat-card .stat-row .value {
    font-weight: 600;
    color: #1a1a2e;
}

.season-stat-card .stat-row .value.positive {
    color: #16a34a;
}

.season-stat-card .stat-row .value.negative {
    color: #dc2626;
}

/* Stats Deep Dive Section */
.target-context-banner {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    margin-bottom: 24px;
}

.target-info {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.target-label {
    font-weight: 500;
    opacity: 0.9;
}

.target-address {
    font-weight: 700;
    font-size: 1.1rem;
}

.target-price {
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
}

.target-ppsf {
    background: rgba(255,255,255,0.15);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.stats-deep-dive-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.deep-dive-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.deep-dive-card.full-width {
    grid-column: 1 / -1;
}

.deep-dive-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 4px;
}

.deep-dive-card .card-subtitle {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 20px;
}

/* Z-Score Card */
.zscore-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.zscore-item {
    text-align: center;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
}

.zscore-label {
    display: block;
    font-size: 0.8rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.zscore-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 4px;
}

.zscore-value.positive {
    color: #dc2626;
}

.zscore-value.negative {
    color: #16a34a;
}

.zscore-value.neutral {
    color: #666;
}

.zscore-interpretation {
    display: block;
    font-size: 0.8rem;
    color: #666;
}

.zscore-scale {
    margin-top: 16px;
}

.scale-bar {
    height: 8px;
    background: linear-gradient(to right, #16a34a, #22c55e, #86efac, #fef08a, #fbbf24, #f97316, #dc2626);
    border-radius: 4px;
    position: relative;
}

.scale-marker {
    position: absolute;
    width: 16px;
    height: 16px;
    background: white;
    border: 3px solid #1a1a2e;
    border-radius: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: left 0.3s ease;
}

.scale-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.75rem;
    color: #888;
}

/* Percentiles Card */
.percentiles-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.percentile-item {
    text-align: center;
    padding: 12px 8px;
    background: #f8f9fa;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.percentile-item.highlight {
    background: #e0e7ff;
    border: 2px solid #2563eb;
}

.percentile-label {
    display: block;
    font-size: 0.7rem;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.percentile-value {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    color: #1a1a2e;
}

.target-percentile {
    text-align: center;
    padding: 12px;
    background: #fef2f2;
    border-radius: 8px;
    border: 1px solid #fecaca;
    font-size: 0.9rem;
    color: #666;
}

.target-pct-value {
    font-weight: 700;
    font-size: 1.2rem;
    color: #dc2626;
    margin: 0 4px;
}

/* Confidence Interval Card */
.ci-display {
    text-align: center;
}

.ci-range {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 24px;
}

.ci-lower, .ci-upper {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a2e;
}

.ci-arrow {
    color: #888;
    font-size: 0.9rem;
}

.ci-visual {
    margin-bottom: 20px;
}

.ci-bar {
    height: 12px;
    background: #e5e7eb;
    border-radius: 6px;
    position: relative;
    overflow: visible;
}

.ci-fill {
    position: absolute;
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    border-radius: 6px;
    transition: all 0.3s ease;
}

.ci-mean-marker {
    position: absolute;
    width: 4px;
    height: 20px;
    background: #1e40af;
    top: 50%;
    transform: translate(-50%, -50%);
    border-radius: 2px;
}

.ci-target-marker {
    position: absolute;
    width: 4px;
    height: 24px;
    background: #dc2626;
    top: 50%;
    transform: translate(-50%, -50%);
    border-radius: 2px;
}

.ci-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.75rem;
    color: #888;
}

.ci-meta {
    display: flex;
    justify-content: center;
    gap: 24px;
    font-size: 0.85rem;
    color: #666;
}

.ci-meta strong {
    color: #1a1a2e;
}

/* IQR Card */
.iqr-display {
    text-align: center;
}

.iqr-value-large {
    font-size: 2.5rem;
    font-weight: 700;
    color: #2563eb;
    margin-bottom: 16px;
}

.iqr-breakdown {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 20px;
}

.iqr-stat {
    text-align: center;
}

.iqr-stat-label {
    display: block;
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 4px;
}

.iqr-stat-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a1a2e;
}

.outlier-bounds {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding: 12px;
    background: #fef3c7;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #92400e;
}

/* Skewness Card */
.skewness-display {
    text-align: center;
}

.skewness-indicator {
    margin-bottom: 20px;
}

.skewness-scale {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.75rem;
    color: #666;
}

.skewness-bar {
    height: 10px;
    background: linear-gradient(to right, #3b82f6, #e5e7eb 40%, #e5e7eb 60%, #f97316);
    border-radius: 5px;
    position: relative;
}

.skew-marker {
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border: 3px solid #1a1a2e;
    border-radius: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: left 0.3s ease;
}

.skewness-value-display {
    margin-bottom: 16px;
}

.skew-number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 4px;
}

.skew-interpretation {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
}

.skew-interpretation.left {
    color: #2563eb;
}

.skew-interpretation.right {
    color: #f97316;
}

.skew-interpretation.center {
    color: #666;
}

.skewness-explanation {
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #555;
    line-height: 1.5;
}

/* Histogram Card */
.histogram-card {
    padding-bottom: 20px;
}

.histogram-container {
    position: relative;
    height: 350px;
    margin-bottom: 16px;
}

.histogram-legend {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
}

.histogram-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #555;
}

.legend-color {
    width: 24px;
    height: 4px;
    border-radius: 2px;
}

.legend-color.target-line {
    background: #dc2626;
    height: 16px;
    width: 4px;
}

.legend-color.mean-line {
    background: #2563eb;
    height: 16px;
    width: 4px;
    border-style: dashed;
}

.legend-color.median-line {
    background: #16a34a;
    height: 16px;
    width: 4px;
}

/* Analysis Tab Styles */
.analysis-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.analysis-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.analysis-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 4px;
}

.analysis-card p {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 16px;
}

/* Predicted Price Card */
.predicted-price-card {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 1px solid #86efac;
}

.predicted-price-content {
    text-align: center;
}

.prediction-main {
    margin-bottom: 16px;
}

.prediction-label {
    display: block;
    font-size: 0.85rem;
    color: #166534;
    margin-bottom: 8px;
}

.prediction-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: #16a34a;
}

.prediction-comparison {
    margin-top: 16px;
}

.comparison-item {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 8px;
}

.comparison-item.over-prediction {
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.comparison-item.under-prediction {
    background: #f0fdf4;
    border: 1px solid #86efac;
}

.comparison-label {
    display: block;
    font-size: 0.85rem;
    color: #666;
}

.comparison-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    margin: 4px 0;
}

.over-prediction .comparison-value {
    color: #dc2626;
}

.under-prediction .comparison-value {
    color: #16a34a;
}

.comparison-note {
    font-size: 0.8rem;
    color: #888;
    margin-top: 8px;
}

/* Regression Card */
.regression-card {
    grid-column: 1 / -1;
}

.regression-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.regression-equation {
    background: #f8f9fa;
    padding: 8px 16px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
}

.regression-equation code {
    font-size: 1rem;
    color: #1a1a2e;
}

.regression-r2 {
    font-size: 0.9rem;
    color: #555;
}

.regression-r2 span:last-child {
    font-weight: 700;
    color: #2563eb;
    font-size: 1.1rem;
    margin-left: 4px;
}

.regression-chart-container {
    position: relative;
    height: 350px;
}

/* Feature Premiums Card */
.premiums-card {
    grid-column: 1 / -1;
}

.premiums-description {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 20px;
}

.premiums-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.premium-item {
    text-align: center;
    padding: 20px 16px;
    background: #f8f9fa;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.premium-item:hover {
    background: #f0f4f8;
}

.premium-label {
    display: block;
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 12px;
    font-weight: 500;
}

.premium-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 8px;
}

.premium-value.positive {
    color: #16a34a;
}

.premium-value.negative {
    color: #dc2626;
}

.premium-detail {
    display: block;
    font-size: 0.75rem;
    color: #888;
    line-height: 1.4;
}

/* Similar Comps Card */
.similar-comps-card {
    grid-column: 1 / -1;
}

.similar-description {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 16px;
}

.similar-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.similar-table th {
    background: #f8f9fa;
    padding: 12px 8px;
    text-align: left;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #555;
    border-bottom: 2px solid #e0e0e0;
}

.similar-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #eee;
}

.similar-table tr:hover {
    background: #f8f9fa;
}

.similar-table td.match {
    color: #16a34a;
    font-weight: 600;
}

.similar-table td.diff {
    color: #666;
}

.sqft-diff {
    font-size: 0.8rem;
    color: #888;
}

.similar-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

.summary-item {
    text-align: center;
    padding: 16px;
    background: #f0fdf4;
    border-radius: 8px;
}

.summary-label {
    display: block;
    font-size: 0.8rem;
    color: #166534;
    margin-bottom: 8px;
}

.summary-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #16a34a;
}

/* Responsive Analysis Tab */
@media (max-width: 768px) {
    .analysis-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .analysis-card {
        padding: 16px;
    }

    .analysis-card h3 {
        font-size: 1rem;
    }

    .predicted-price-card {
        order: -1;
    }

    .prediction-value {
        font-size: 2rem;
    }

    .regression-stats {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .regression-chart-container {
        height: 280px;
    }

    .premiums-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .premium-item {
        padding: 16px;
    }

    .premium-value {
        font-size: 1.5rem;
    }

    .similar-table {
        font-size: 0.8rem;
    }

    .similar-table th,
    .similar-table td {
        padding: 8px 6px;
    }

    .similar-summary {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .summary-value {
        font-size: 1.25rem;
    }
}

/* Footer */
footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    text-align: center;
    color: #888;
    font-size: 0.85rem;
}

footer .sources {
    margin-top: 8px;
}

footer a {
    color: #2563eb;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

    header h1 {
        font-size: 1.4rem;
    }

    header .subtitle {
        font-size: 0.9rem;
    }

    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .tabs::-webkit-scrollbar {
        display: none;
    }

    .tab {
        padding: 10px 14px;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .controls {
        flex-direction: column;
        gap: 12px;
    }

    .filter-group {
        width: 100%;
        justify-content: space-between;
    }

    .filter-group select {
        flex: 1;
        max-width: 200px;
    }

    .toggle-group {
        justify-content: flex-start;
    }

    #map {
        height: 300px;
        border-radius: 8px;
    }

    .stats-panel {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 14px 10px;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .legend {
        padding: 12px;
    }

    .legend h4 {
        font-size: 0.9rem;
        margin-bottom: 8px;
    }

    .legend-item {
        font-size: 0.8rem;
        gap: 8px;
        margin-bottom: 6px;
    }

    .marker-icon {
        width: 16px;
        height: 16px;
    }

    .heatmap-legend {
        flex-wrap: wrap;
    }

    .heatmap-gradient {
        width: 100%;
        height: 12px;
        margin-bottom: 4px;
    }

    /* Data Table Controls Mobile */
    .data-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px;
    }

    .data-search {
        max-width: none;
    }

    .data-actions {
        justify-content: space-between;
    }

    .btn-export {
        padding: 8px 14px;
        font-size: 0.85rem;
    }

    /* Tables - horizontal scroll */
    #data-table,
    #price-diff-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-wrapper {
        margin: 0 -12px;
        padding: 0 12px;
    }

    table {
        min-width: 600px;
    }

    th, td {
        padding: 10px 8px;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    .table-info {
        font-size: 0.75rem;
        padding: 10px 12px;
    }

    .sort-arrow {
        font-size: 0.6rem;
    }

    .summary-row td {
        font-size: 0.8rem;
    }

    .pagination {
        padding: 12px;
        gap: 10px;
    }

    .pagination button {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .pagination span {
        font-size: 0.8rem;
    }

    /* Price diff stats */
    .price-diff-stats {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .stat-card.wide {
        min-width: unset;
    }

    .chart-container {
        padding: 16px;
        max-height: 300px;
    }

    /* Trends responsive */
    .trends-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .chart-card {
        padding: 16px;
    }

    .chart-card h3 {
        font-size: 1rem;
    }

    .chart-container-trends {
        height: 220px;
    }

    .seasonality-container {
        flex-direction: column;
        gap: 16px;
    }

    .seasonality-stats {
        min-width: unset;
        width: 100%;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .season-stat-card {
        padding: 12px;
    }

    .season-stat-card h4 {
        font-size: 0.8rem;
    }

    .season-stat-card .stat-row {
        font-size: 0.75rem;
    }

    footer {
        margin-top: 24px;
        font-size: 0.75rem;
    }

    footer .sources {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    /* Stats Deep Dive Mobile */
    .target-context-banner {
        padding: 12px 16px;
    }

    .target-info {
        gap: 8px;
        justify-content: center;
        text-align: center;
    }

    .target-address {
        font-size: 1rem;
        width: 100%;
    }

    .stats-deep-dive-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .deep-dive-card {
        padding: 16px;
    }

    .deep-dive-card h3 {
        font-size: 1rem;
    }

    .zscore-grid {
        gap: 12px;
    }

    .zscore-item {
        padding: 12px;
    }

    .zscore-value {
        font-size: 1.5rem;
    }

    .percentiles-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .percentile-item {
        padding: 10px 6px;
    }

    .percentile-label {
        font-size: 0.65rem;
    }

    .percentile-value {
        font-size: 0.85rem;
    }

    .ci-lower, .ci-upper {
        font-size: 1.2rem;
    }

    .ci-meta {
        flex-wrap: wrap;
        gap: 12px;
    }

    .iqr-value-large {
        font-size: 2rem;
    }

    .iqr-breakdown {
        gap: 20px;
    }

    .outlier-bounds {
        flex-direction: column;
        gap: 8px;
    }

    .histogram-container {
        height: 280px;
    }

    .histogram-legend {
        gap: 12px;
        font-size: 0.8rem;
    }
}

/* Extra small screens */
@media (max-width: 400px) {
    .container {
        padding: 8px;
    }

    header h1 {
        font-size: 1.2rem;
    }

    .tab {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    #map {
        height: 260px;
    }

    .stats-panel {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .stat-card {
        padding: 12px 8px;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    .legend {
        padding: 10px;
    }

    /* Stats Deep Dive Extra Small */
    .zscore-grid {
        grid-template-columns: 1fr;
    }

    .percentiles-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .percentile-item:nth-child(5) {
        grid-column: 1 / -1;
    }
}

/* ============================================
   ADVANCED ANALYTICS TAB
   ============================================ */

.advanced-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.advanced-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.advanced-card.full-width {
    grid-column: 1 / -1;
}

.advanced-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 4px;
}

.advanced-card .card-subtitle {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 16px;
}

/* Hedonic Regression */
.hedonic-equation {
    font-family: 'Monaco', 'Consolas', monospace;
    background: #f5f7fa;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    overflow-x: auto;
    margin-bottom: 12px;
}

.hedonic-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.hedonic-stats strong {
    color: #2563eb;
}

.hedonic-coefficients {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.coef-item {
    background: #f5f7fa;
    padding: 12px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

.coef-name {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 4px;
}

.coef-value {
    font-size: 1.1rem;
    font-weight: 600;
}

.coef-value.positive { color: #16a34a; }
.coef-value.negative { color: #dc2626; }

.coef-pvalue {
    font-size: 0.75rem;
    color: #888;
    margin-top: 2px;
}

.hedonic-prediction {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    padding: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.pred-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.pred-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.pred-diff {
    font-size: 0.9rem;
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 20px;
}

/* Anomalies List */
#anomalies-list {
    max-height: 300px;
    overflow-y: auto;
}

.anomaly-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.anomaly-item:last-child {
    border-bottom: none;
}

.anomaly-address {
    font-size: 0.85rem;
    font-weight: 500;
}

.anomaly-details {
    font-size: 0.8rem;
    color: #666;
}

.anomaly-diff {
    font-size: 0.9rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 4px;
}

.anomaly-diff.over {
    background: #dcfce7;
    color: #16a34a;
}

.anomaly-diff.under {
    background: #fee2e2;
    color: #dc2626;
}

/* Monte Carlo */
.monte-carlo-results {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.mc-chart-container {
    height: 200px;
}

.mc-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mc-stat-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.mc-stat-label {
    font-size: 0.85rem;
    color: #666;
}

.mc-stat-value {
    font-weight: 600;
}

/* Chart containers */
.kde-chart-container,
.boxplot-container,
.rolling-chart-container,
.decade-chart-container,
.ppsf-beds-container,
.distance-chart-container,
.qq-chart-container {
    height: 250px;
    position: relative;
}

.rolling-chart-container {
    height: 300px;
}

/* Q-Q Interpretation */
.qq-interpretation {
    margin-top: 12px;
    padding: 12px;
    background: #f5f7fa;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #555;
}

/* Market Metrics */
.market-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.metric-item {
    background: #f5f7fa;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
}

.metric-label {
    font-size: 0.75rem;
    color: #666;
    display: block;
    margin-bottom: 4px;
}

.metric-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1a1a2e;
}

.metric-note {
    font-size: 0.7rem;
    color: #888;
    margin-top: 2px;
}

/* Confidence Score */
.confidence-score {
    text-align: center;
}

.confidence-gauge {
    width: 150px;
    height: 150px;
    margin: 0 auto 16px;
    position: relative;
}

.confidence-ring {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(
        #22c55e var(--score-pct, 0%),
        #e5e7eb var(--score-pct, 0%)
    );
    display: flex;
    align-items: center;
    justify-content: center;
}

.confidence-ring::before {
    content: '';
    position: absolute;
    width: 110px;
    height: 110px;
    background: white;
    border-radius: 50%;
}

.confidence-value {
    position: relative;
    font-size: 2rem;
    font-weight: 700;
    color: #1a1a2e;
}

.confidence-factors {
    text-align: left;
    font-size: 0.85rem;
}

.confidence-factor {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #eee;
}

.factor-label {
    color: #666;
}

.factor-value {
    font-weight: 500;
}

.factor-value.good { color: #16a34a; }
.factor-value.ok { color: #f59e0b; }
.factor-value.poor { color: #dc2626; }

/* Responsive */
@media (max-width: 768px) {
    .advanced-grid {
        grid-template-columns: 1fr;
    }

    .monte-carlo-results {
        grid-template-columns: 1fr;
    }

    .hedonic-stats {
        flex-wrap: wrap;
        gap: 12px;
    }

    .hedonic-prediction {
        flex-direction: column;
        text-align: center;
    }
}
