/* === Базовые стили === */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

a { color: #2e7d32; text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* === Шапка === */
.header {
    background: linear-gradient(135deg, #2e7d32, #1b5e20);
    color: #fff; padding: 40px 20px; text-align: center;
}
.header h1 { font-size: 2em; margin-bottom: 8px; }
.subtitle { opacity: 0.9; font-size: 1.05em; }

/* === Метрики === */
.metrics { display: flex; gap: 16px; margin: -30px auto 20px; position: relative; z-index: 1; flex-wrap: wrap; }
.metric-card {
    flex: 1; min-width: 200px; background: #fff; border-radius: 12px;
    padding: 24px; text-align: center; box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.metric-value { font-size: 1.8em; font-weight: bold; color: #2e7d32; }
.metric-label { color: #666; margin-top: 4px; font-size: 0.9em; }

/* === Топ-10 === */
.tops-section { margin: 30px 0; }
.tops-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.top-block {
    background: #fff; border-radius: 12px; padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.top-block h3 { margin-bottom: 12px; font-size: 1.1em; }
.top-block ol { padding-left: 20px; }
.top-block li { padding: 4px 0; font-size: 0.95em; }
.top-block li a { color: #333; }
.top-block li a:hover { color: #2e7d32; }
.top-block li strong { color: #2e7d32; }

/* === Графики === */
.chart-section { margin: 30px 0; }
.chart-section h2 { margin-bottom: 16px; }
.chart-container {
    background: #fff; border-radius: 12px; padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08); overflow: visible;
}
.bar-chart { display: flex; align-items: flex-end; gap: 8px; padding: 10px 20px 10px 0; overflow-x: auto; }
.bar-group { flex: 1; min-width: 60px; display: flex; flex-direction: column; align-items: center; }
.bar {
    width: 28px; border-radius: 4px 4px 0 0; min-height: 2px;
    transition: height 0.3s, opacity 0.2s;
}
.bar:hover { opacity: 0.8; }
.bar.land, .bar:not(.apt):not(.bld) { background: #4CAF50; }
.bar.apt { background: #2196F3; }
.bar.bld { background: #FF9800; }
.bar-label { font-size: 0.72em; color: #666; margin-top: 6px; text-align: center; white-space: nowrap; }
.bar-value { font-size: 0.68em; color: #333; font-weight: bold; margin-bottom: 2px; text-align: center; }
.legend { display: flex; gap: 20px; margin-top: 12px; justify-content: center; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.85em; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; }

/* === Карта === */
.map-section { margin: 30px 0; }
.map-section h2 { margin-bottom: 16px; }
#map { border: 2px solid #e0e0e0; }
.leaflet-attribution-container a[href*="leaflet"] svg { display: none; }

/* === Таблица === */
.table-section { margin: 30px 0; }
.table-section h2 { margin-bottom: 16px; }

.table-controls {
    display: flex; gap: 12px; margin-bottom: 16px;
    flex-wrap: wrap; align-items: center;
}
.search-input {
    flex: 1; min-width: 200px; padding: 10px 16px;
    border: 2px solid #e0e0e0; border-radius: 8px;
    font-size: 1em; outline: none; transition: border-color 0.2s;
}
.search-input:focus { border-color: #2e7d32; }

.table-controls select {
    padding: 10px 12px; border: 2px solid #e0e0e0;
    border-radius: 8px; font-size: 0.9em; background: #fff;
    cursor: pointer; outline: none;
}
.table-controls select:focus { border-color: #2e7d32; }

.price-filter {
    display: flex; align-items: center; gap: 6px; font-size: 0.9em;
}
.price-input {
    width: 90px; padding: 10px 8px; border: 2px solid #e0e0e0;
    border-radius: 8px; font-size: 0.9em; outline: none;
}
.price-input:focus { border-color: #2e7d32; }

.table-info { color: #888; font-size: 0.85em; margin-bottom: 8px; }

.table-responsive { overflow-x: auto; }

.data-table {
    width: 100%; border-collapse: collapse; background: #fff;
    border-radius: 12px; overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.data-table thead th {
    background: #2e7d32; color: #fff; padding: 12px 16px;
    text-align: left; font-size: 0.9em; white-space: nowrap;
}
.data-table td {
    padding: 10px 16px; border-bottom: 1px solid #f0f0f0;
    font-size: 0.95em;
}
.data-table tr:hover { background: #f9fbe7; }
.data-table td a { font-weight: 500; }

/* === SEO-текст === */
.seo-text {
    background: #fff; border-radius: 12px; padding: 30px;
    margin: 30px 0; box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.seo-text h2 { margin-bottom: 12px; color: #2e7d32; }
.seo-text p { margin-bottom: 10px; color: #555; }

/* === Футер === */
.footer {
    background: #333; color: #aaa; padding: 30px 20px;
    text-align: center; margin-top: 40px;
}
.footer a { color: #81c784; }
.footer p { margin: 4px 0; font-size: 0.9em; }

/* === Мобильная адаптация === */
@media (max-width: 768px) {
    .header h1 { font-size: 1.4em; }
    .header { padding: 24px 16px; }

    .metrics { flex-direction: column; margin-top: -20px; }
    .metric-card { padding: 16px; }
    .metric-value { font-size: 1.4em; }

    .tops-grid { grid-template-columns: 1fr; }

    .table-controls { flex-direction: column; }
    .search-input { min-width: 100%; }
    .price-filter { flex-wrap: wrap; }
    .price-input { width: 70px; }

    #map { height: 300px !important; }

    .data-table thead th { padding: 8px 10px; font-size: 0.8em; }
    .data-table td { padding: 8px 10px; font-size: 0.85em; }

    .bar-group { min-width: 50px; }
    .bar { width: 20px; }

    .seo-text { padding: 20px; }
}

@media (max-width: 480px) {
    .header h1 { font-size: 1.2em; }
    .metric-value { font-size: 1.2em; }
    .container { padding: 0 12px; }

    .data-table td:nth-child(3) { display: none; }
    .data-table th:nth-child(3) { display: none; }

    .price-filter { display: none; }
}

/* Районы — раскрытие городов */
.district-row:hover { background: #f0f7ff; }
.expand-icon { display: inline-block; width: 16px; font-size: 10px; color: #999; transition: transform 0.2s; }
.cities-row td { padding: 0 !important; background: #f8fafe; }
.cities-grid { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; }
.city-chip { background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; padding: 8px 12px; font-size: 13px; display: flex; flex-direction: column; gap: 2px; min-width: 160px; }
.city-chip strong { font-size: 14px; color: #1a1a2e; }
.city-chip span { color: #666; font-size: 12px; }
.deals-badge { background: #e3f2fd; color: #1565c0; border-radius: 4px; padding: 1px 6px; font-size: 11px; align-self: flex-start; margin-top: 2px; }
.back-link { color: rgba(255,255,255,0.8); text-decoration: none; font-size: 14px; display: inline-block; margin-bottom: 4px; }
.back-link:hover { color: #fff; }

python -c "
css = '''
/* Карточки на странице региона */
.card { flex: 1; min-width: 150px; background: #fff; border-radius: 12px; padding: 20px; text-align: center; box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
.card .value { font-size: 1.6rem; font-weight: 700; color: #2e7d32; }
.card .label { font-size: 0.85rem; color: #666; margin-top: 4px; }

/* Города в районах */
.district-row:hover { background: #f0f7ff; }
.expand-icon { display: inline-block; width: 16px; font-size: 10px; color: #999; }
.cities-row td { padding: 0 !important; background: #f8fafe; }
.cities-grid { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; }
.city-chip { background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; padding: 8px 12px; font-size: 13px; display: flex; flex-direction: column; gap: 2px; min-width: 160px; }
.city-chip strong { font-size: 14px; color: #1a1a2e; }
.city-chip span { color: #666; font-size: 12px; }
.deals-badge { background: #e3f2fd; color: #1565c0; border-radius: 4px; padding: 1px 6px; font-size: 11px; align-self: flex-start; margin-top: 2px; }
.back-link { color: rgba(255,255,255,0.8); text-decoration: none; font-size: 14px; display: inline-block; margin-bottom: 4px; }
.back-link:hover { color: #fff; }
'''
with open('css/style.css', 'a', encoding='utf-8') as f:
    f.write(css)
print('CSS patched!')
"
.metrics { display: flex; flex-wrap: wrap; gap: 16px; margin: 24px 0; }
.card { flex: 1 1 180px; min-width: 150px; max-width: 250px; background: #fff; border-radius: 12px; padding: 16px 20px; text-align: center; box-shadow: 0 4px 15px rgba(0,0,0,0.08); }
.card .value { font-size: 1.4rem; font-weight: 700; color: #2e7d32; white-space: nowrap; }
.card .label { font-size: 0.8rem; color: #666; margin-top: 4px; line-height: 1.3; }

.bar-value { font-size: 11px; color: #333; text-align: center; white-space: nowrap; margin-bottom: 2px; overflow: visible; }
.bar-group { min-width: 60px; }
