/* ==========================================================================
   ПОГОДНАЯ АНАЛИТИКА — ЧИСТЫЙ UI/UX ДАШБОРД
   Нейтральный графит (тёмная) / мягкий слейт (светлая)
   Ограниченная ширина без горизонтальных вылетов за пределы экрана
   ========================================================================== */

/* ==================== 1. ПЕРЕМЕННЫЕ И ТЕМЫ ==================== */
:root {
    /* Светлая тема */
    --bg-app: #f4f6fa;
    --bg-card: #ffffff;
    --bg-card-subtle: #f8fafc;
    --bg-card-hover: #f1f5f9;
    --border-color: #e2e8f0;
    --border-subtle: rgba(0, 0, 0, 0.05);

    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-dim: #94a3b8;

    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-glow: rgba(2, 132, 199, 0.12);
    --primary-surface: #e0f2fe;

    --accent-warm: #f97316;
    --accent-emerald: #10b981;
    --accent-rain: #0284c7;
    --danger: #ef4444;

    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
    --shadow-card: 0 4px 16px -2px rgba(15, 23, 42, 0.05), 0 2px 6px -1px rgba(15, 23, 42, 0.02);
    --shadow-hover: 0 10px 24px -4px rgba(15, 23, 42, 0.08);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    /* Тёмная тема — нейтральный графит/обсидиан, без фиолетового и синего */
    --bg-app: #0f1115;
    --bg-card: #17191f;
    --bg-card-subtle: #1f222b;
    --bg-card-hover: #262a35;
    --border-color: #2b303c;
    --border-subtle: rgba(255, 255, 255, 0.06);

    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --primary: #38bdf8;
    --primary-hover: #7dd3fc;
    --primary-glow: rgba(56, 189, 248, 0.16);
    --primary-surface: rgba(56, 189, 248, 0.1);

    --accent-warm: #fb923c;
    --accent-emerald: #34d399;
    --accent-rain: #38bdf8;
    --danger: #f87171;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.35);
    --shadow-hover: 0 10px 30px -4px rgba(0, 0, 0, 0.55);
}

/* ==================== 2. СТРОГИЕ БАЗОВЫЕ ОГРАНИЧЕНИЯ ==================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    transition: background-color 0.25s ease, color 0.25s ease;
}

/* Ограничиваем контейнер по ширине, чтобы ничего не расползалось вправо */
.app-layout {
    max-width: 1240px;
    width: 100%;
    margin: 0 auto;
    padding: 20px 24px 60px;
    min-width: 0;
}

/* Все flex и grid контейнеры должны иметь min-width: 0, чтобы scrollable дети не раздували страницу */
.grid-left,
.grid-right,
.content-card,
.dashboard-grid,
.city-bar-section,
.analytics-card {
    min-width: 0;
}

/* ==================== 3. ШАПКА ==================== */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    font-size: 26px;
    line-height: 1;
}

.brand-info h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-main);
    line-height: 1.2;
}

.brand-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-header-add {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: var(--primary);
    color: #0f172a;
    border: none;
    padding: 9px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

[data-theme="dark"] .btn-header-add {
    color: #0b0d10;
}

.btn-header-add:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-icon {
    font-size: 16px;
    font-weight: 800;
}

.theme-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.theme-toggle-btn:hover {
    background-color: var(--bg-card-hover);
    border-color: var(--text-muted);
}

/* ==================== 4. ПОЛОСА ГОРОДОВ ==================== */
.city-bar-section {
    width: 100%;
    margin-bottom: 22px;
}

.city-bar-wrapper {
    display: flex;
    align-items: stretch;
    gap: 12px;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.city-bar-wrapper::-webkit-scrollbar {
    height: 6px;
}

.city-bar-wrapper::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
}

.city-pill-card {
    position: relative;
    flex: 0 0 175px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.city-pill-card:hover {
    transform: translateY(-2px);
    border-color: var(--text-muted);
    box-shadow: var(--shadow-card);
}

.city-pill-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow), var(--shadow-card);
    background-color: var(--bg-card);
}

.city-pill-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 6px;
}

.city-pill-title-wrap {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.city-pill-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.city-pill-indicator {
    font-size: 10px;
    font-weight: 700;
    color: var(--primary);
    margin-top: 1px;
}

.city-pill-remove {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.city-pill-remove:hover {
    background-color: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.city-pill-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.city-pill-icon {
    font-size: 22px;
}

.city-pill-temp {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
}

.city-pill-desc {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.city-pill-add-card {
    flex: 0 0 145px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background-color: transparent;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    padding: 10px;
}

.city-pill-add-card:hover {
    border-color: var(--primary);
    color: var(--primary);
    background-color: var(--primary-surface);
}

.city-pill-add-card .add-icon {
    font-size: 18px;
    font-weight: 800;
}

.city-pill-add-card .add-text {
    font-size: 11px;
    font-weight: 600;
}

/* ==================== 5. СЕТКА ДАШБОРДА ==================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 375px 1fr;
    gap: 20px;
    margin-bottom: 22px;
}

.grid-left {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.grid-right {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
}

.content-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-card);
    transition: var(--transition);
}

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

.card-title-group h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
}

.card-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
    display: block;
}

/* ==================== 6. HERO-КАРТОЧКА ==================== */
.hero-card {
    border-radius: var(--radius-lg);
    padding: 22px;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 290px;
    background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
}

.hero-theme-clear {
    background: linear-gradient(145deg, #2563eb 0%, #1e3a8a 100%);
}
[data-theme="dark"] .hero-theme-clear {
    background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid #334155;
}

.hero-theme-cloudy,
.hero-theme-overcast {
    background: linear-gradient(145deg, #334155 0%, #1e293b 100%);
}
[data-theme="dark"] .hero-theme-cloudy,
[data-theme="dark"] .hero-theme-overcast {
    background: linear-gradient(145deg, #232731 0%, #15181e 100%);
    border: 1px solid #333844;
}

.hero-theme-rain {
    background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
}
[data-theme="dark"] .hero-theme-rain {
    background: linear-gradient(145deg, #1a202c 0%, #101520 100%);
    border: 1px solid #28334a;
}

.hero-theme-snow {
    background: linear-gradient(145deg, #475569 0%, #1e293b 100%);
}

.hero-theme-storm {
    background: linear-gradient(145deg, #1e1b4b 0%, #09090b 100%);
}

.hero-top-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.hero-location-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.hero-location-row .location-icon {
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
}

.hero-city-name {
    font-size: 24px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.hero-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
}

.hero-date {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.78);
    font-weight: 500;
}

.hero-weather-tag {
    background: rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(8px);
    padding: 4px 12px;
    border-radius: 14px;
    font-size: 12px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
}

.hero-center {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 16px 0;
}

.hero-temp-wrapper {
    display: flex;
    align-items: flex-start;
}

.hero-temp-sign {
    font-size: 32px;
    font-weight: 600;
    margin-top: 6px;
}

.hero-temp-value {
    font-size: 64px;
    font-weight: 800;
    line-height: 0.95;
    letter-spacing: -1.5px;
}

.hero-temp-unit {
    font-size: 24px;
    font-weight: 500;
    margin-top: 6px;
    opacity: 0.8;
}

.hero-icon-large {
    font-size: 56px;
}

/* Просторный блок статистики: 2 колонки + полная строка солнца без обрезания текста */
.hero-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
}

.hero-stat-box {
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    min-width: 0;
}

.hero-stat-box .stat-label {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 3px;
    text-align: center;
}

.hero-stat-box .stat-value {
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    text-align: center;
}

.hero-stat-box-full {
    grid-column: 1 / -1;
    width: 100%;
    align-items: center;
    text-align: center;
}

.stat-sun-times {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    font-size: 14px;
    color: #ffffff;
    margin-top: 2px;
    width: 100%;
}

.stat-sun-times .sun-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-sun-times .sun-item b {
    font-weight: 700;
}

.stat-sun-times .sun-sep {
    color: rgba(255, 255, 255, 0.4);
    font-size: 12px;
}

/* ==================== 7. ПРОГНОЗ НА 7 ДНЕЙ ==================== */
.weekly-forecast-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.forecast-row {
    display: grid;
    grid-template-columns: 75px 55px 32px 1fr 32px;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.forecast-row:last-child {
    border-bottom: none;
}

.forecast-day-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
}

.forecast-condition {
    display: flex;
    align-items: center;
    gap: 4px;
}

.forecast-icon {
    font-size: 18px;
}

.forecast-rain-badge {
    font-size: 10px;
    font-weight: 600;
    color: var(--accent-rain);
}

.forecast-temp-min {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: right;
}

.forecast-temp-max {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-main);
    text-align: left;
}

.forecast-range-track {
    position: relative;
    height: 6px;
    background-color: var(--bg-card-subtle);
    border-radius: 999px;
    overflow: hidden;
}

.forecast-range-bar {
    position: absolute;
    top: 0;
    bottom: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--accent-warm) 100%);
}

/* ==================== 8. ПОЧАСОВОЙ ПРОГНОЗ ==================== */
.hourly-card {
    width: 100%;
}

.hourly-scroll-strip {
    display: flex;
    gap: 10px;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.hourly-scroll-strip::-webkit-scrollbar {
    height: 6px;
}

.hourly-scroll-strip::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
}

.hourly-item {
    flex: 0 0 72px;
    background-color: var(--bg-card-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 6px;
    text-align: center;
    transition: var(--transition);
}

.hourly-item:hover {
    background-color: var(--bg-card-hover);
    transform: translateY(-2px);
}

.hourly-item.current {
    border-color: var(--primary);
    background-color: var(--primary-surface);
    box-shadow: 0 0 0 1px var(--primary-glow);
}

.hourly-time {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.hourly-icon {
    font-size: 22px;
    margin-bottom: 6px;
}

.hourly-temp {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}

.hourly-rain {
    font-size: 10px;
    font-weight: 600;
    color: var(--accent-rain);
}

.hourly-rain.empty {
    color: var(--text-dim);
}

/* ==================== 9. КАРТОЧКИ ПОКАЗАТЕЛЕЙ ==================== */
.highlights-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 16px;
    width: 100%;
    flex: 1;
}

.highlight-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    min-height: 140px;
    padding: 18px 20px;
}

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

.highlight-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.highlight-icon {
    font-size: 18px;
}

.highlight-huge-val {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.highlight-sub-val {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 2px;
}

.highlight-desc-text {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 6px;
    line-height: 1.3;
}

/* Компас ветра */
.highlight-wind {
    grid-column: span 1;
}

.wind-widget-body {
    display: flex;
    align-items: center;
    gap: 16px;
}

.compass-circle {
    position: relative;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background-color: var(--bg-card-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.compass-mark {
    position: absolute;
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    line-height: 1;
}

.mark-n { top: 3px; }
.mark-e { right: 5px; }
.mark-s { bottom: 3px; }
.mark-w { left: 5px; }

.compass-needle {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.needle-pointer {
    position: absolute;
    top: 8px;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 22px solid var(--accent-warm);
}

.compass-center-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-main);
    z-index: 2;
}

.wind-widget-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* 3-сегментная шкала влажности (исправлено равенство колонок) */
.segmented-meter {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    width: 100%;
    margin-top: 10px;
}

.meter-segment {
    text-align: center;
    padding: 5px 0;
    font-size: 10px;
    font-weight: 600;
    border-radius: 6px;
    background-color: var(--bg-card-subtle);
    color: var(--text-dim);
    border: 1px solid transparent;
}

.meter-hum-dry .seg-dry {
    background-color: rgba(251, 146, 60, 0.2);
    color: var(--accent-warm);
    border-color: var(--accent-warm);
}

.meter-hum-normal .seg-normal {
    background-color: rgba(52, 211, 153, 0.2);
    color: var(--accent-emerald);
    border-color: var(--accent-emerald);
}

.meter-hum-humid .seg-humid {
    background-color: rgba(56, 189, 248, 0.2);
    color: var(--primary);
    border-color: var(--primary);
}

/* Прогресс-бар */
.progress-bar-track {
    height: 7px;
    background-color: var(--bg-card-subtle);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 12px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent-rain));
    border-radius: 999px;
    transition: width 0.4s ease;
}

.progress-cloud {
    background: linear-gradient(90deg, #64748b, #94a3b8);
}

/* ==================== 10. АНАЛИТИКА ==================== */
.analytics-section {
    width: 100%;
    margin-top: 4px;
}

.analytics-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.analytics-header h2 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-main);
}

.analytics-nav-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.analytics-tab-btn {
    background-color: var(--bg-card-subtle);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.analytics-tab-btn:hover {
    background-color: var(--bg-card-hover);
    color: var(--text-main);
}

.analytics-tab-btn.active {
    background-color: var(--primary);
    color: #0f172a;
    border-color: var(--primary);
    font-weight: 700;
}

[data-theme="dark"] .analytics-tab-btn.active {
    color: #0b0d10;
}

.analytics-tab-pane {
    display: none;
}

.analytics-tab-pane.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

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

.chart-wrapper {
    position: relative;
    height: 360px;
    width: 100%;
    margin-bottom: 16px;
}

.chart-wrapper.chart-wrapper-half {
    height: 290px;
    margin-bottom: 0;
}

/* Двойная сетка графиков ветра */
.wind-charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

@media (max-width: 860px) {
    .wind-charts-grid {
        grid-template-columns: 1fr;
    }
}

.wind-chart-card {
    background-color: var(--bg-card-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 16px 12px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.wind-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.wind-chart-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
}

.wind-chart-subtitle {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
}

/* Блок сравнительных метео-инсайтов (KPI) */
.analytics-kpi-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.kpi-insight-card {
    background-color: var(--bg-card-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 14px 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: var(--transition);
}

.kpi-insight-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

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

.kpi-insight-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.kpi-insight-icon {
    font-size: 16px;
}

.kpi-insight-val {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.kpi-insight-sub {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Радар климатического комфорта */
.radar-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    align-items: start;
}

.chart-wrapper-radar {
    height: 400px;
}

.comfort-summary-panel {
    background-color: var(--bg-card-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
}

.comfort-cards-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.comfort-city-item {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: var(--transition);
}

.comfort-city-item:hover {
    border-color: var(--primary);
    transform: translateX(2px);
}

.comfort-city-item.active-comfort-city {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.comfort-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.comfort-rank {
    font-size: 12px;
    font-weight: 800;
    color: var(--text-dim);
    width: 20px;
}

.comfort-city-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
}

.comfort-tip {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
}

.comfort-item-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.comfort-score-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 800;
}

.badge-comfort-ideal {
    background-color: rgba(52, 211, 153, 0.18);
    color: var(--accent-emerald);
}

.badge-comfort-good {
    background-color: rgba(56, 189, 248, 0.18);
    color: var(--primary);
}

.badge-comfort-cool {
    background-color: rgba(251, 146, 60, 0.18);
    color: var(--accent-warm);
}

.badge-comfort-bad {
    background-color: rgba(248, 113, 113, 0.18);
    color: var(--danger);
}

.comfort-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-dim);
}

/* Недельный баланс осадков */
.precip-summary-section {
    margin-top: 24px;
}

.precip-cities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
}

.precip-city-card {
    background-color: var(--bg-card-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    cursor: pointer;
    transition: var(--transition);
}

.precip-city-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.precip-city-card.active-precip-city {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.precip-city-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.precip-city-top h4 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
}

.precip-city-total {
    font-size: 15px;
    font-weight: 800;
    color: var(--accent-rain);
}

.precip-city-bar-track {
    height: 6px;
    background-color: var(--bg-card);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 10px;
}

.precip-city-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent-rain));
    border-radius: 999px;
}

.precip-city-stats {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 11px;
    color: var(--text-muted);
}

.precip-city-stats b {
    color: var(--text-main);
}

/* ==================== 11. ТАБЛИЦЫ ==================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-card);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}

th, td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
}

th {
    background-color: var(--bg-card-subtle);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th:hover {
    color: var(--text-main);
}

th.sort-asc::after { content: " ▲"; color: var(--primary); }
th.sort-desc::after { content: " ▼"; color: var(--primary); }

tbody tr:hover {
    background-color: var(--bg-card-hover);
}

.table-row-active {
    background-color: var(--primary-surface);
}

.table-city-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-weather-icon {
    font-size: 18px;
}

.pill-active-mini {
    font-size: 9px;
    font-weight: 700;
    background-color: var(--primary);
    color: #0f172a;
    padding: 2px 6px;
    border-radius: 10px;
    text-transform: uppercase;
}

[data-theme="dark"] .pill-active-mini {
    color: #0b0d10;
}

.temp-warm { color: var(--accent-warm); }
.temp-cold { color: var(--primary); }

.table-progress-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mini-bar-bg {
    width: 50px;
    height: 5px;
    background-color: var(--bg-card-subtle);
    border-radius: 99px;
    overflow: hidden;
}

.mini-bar-fill {
    height: 100%;
    background-color: var(--primary);
}

.table-wind-dir {
    display: flex;
    align-items: center;
    gap: 6px;
}

.wind-arrow-mini {
    display: inline-block;
    font-weight: 800;
    color: var(--accent-warm);
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 12px;
}

.badge-speed {
    background-color: var(--bg-card-subtle);
    color: var(--text-main);
}

.badge-gusts {
    background-color: rgba(251, 146, 60, 0.15);
    color: var(--accent-warm);
}

.badge-precip {
    color: var(--accent-rain);
    font-weight: 700;
}

.table-sub-wrapper {
    margin-top: 20px;
}

.table-sub-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-main);
}

.table-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 10px;
}

/* ==================== 12. МОДАЛЬНОЕ ОКНО ПОИСКА ГОРОДА ==================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    padding: 20px;
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 580px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-hover);
    transform: scale(0.96);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.modal-backdrop.open .modal-box {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title-wrap h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
}

.modal-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close-btn:hover {
    background-color: var(--bg-card-subtle);
    color: var(--text-main);
}

.modal-search-bar {
    position: relative;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-search-icon {
    position: absolute;
    left: 40px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: var(--text-muted);
}

.modal-search-input {
    width: 100%;
    padding: 12px 16px 12px 42px;
    background-color: var(--bg-card-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.modal-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    max-height: 55vh;
}

.modal-section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* Сетка популярных городов */
.popular-cities-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.popular-city-chip {
    background-color: var(--bg-card-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.popular-city-chip:hover {
    background-color: var(--bg-card-hover);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.popular-city-chip.is-added {
    opacity: 0.6;
    border-style: dashed;
}

.chip-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
}

.chip-status {
    font-size: 11px;
    color: var(--accent-emerald);
    font-weight: 800;
}

.chip-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Список результатов живого поиска */
.modal-results-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.modal-city-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background-color: var(--bg-card-subtle);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.modal-city-row:hover:not(.already-added) {
    background-color: var(--bg-card-hover);
    border-color: var(--primary);
    transform: translateX(2px);
}

.modal-city-row.already-added {
    opacity: 0.65;
    cursor: default;
}

.modal-city-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
}

.modal-city-region {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.btn-select-city {
    background-color: var(--primary-surface);
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.btn-select-city:hover {
    background-color: var(--primary);
    color: #0f172a;
}

[data-theme="dark"] .btn-select-city:hover {
    color: #0b0d10;
}

.badge-added {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
}

.modal-loading-state,
.modal-empty-state {
    text-align: center;
    padding: 30px 10px;
    color: var(--text-muted);
}

.modal-empty-state p {
    font-weight: 600;
    color: var(--text-main);
    margin: 8px 0 4px;
}

.modal-empty-state span {
    font-size: 12px;
    color: var(--text-dim);
}

/* ==================== 13. СЛУЖЕБНЫЕ ==================== */
.error-toast {
    display: none;
    background-color: var(--danger);
    color: #ffffff;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 18px;
    animation: slideDown 0.3s ease;
}

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

.loader-backdrop {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: var(--primary);
    font-weight: 600;
    font-size: 13px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 70px 20px;
    text-align: center;
    background-color: var(--bg-card);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-xl);
}

.empty-icon {
    font-size: 42px;
    margin-bottom: 14px;
}

.empty-state h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 13px;
    color: var(--text-muted);
    max-width: 380px;
    margin-bottom: 20px;
}

.btn-primary {
    background-color: var(--primary);
    color: #0f172a;
    border: none;
    padding: 10px 22px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

[data-theme="dark"] .btn-primary {
    color: #0b0d10;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

/* ==================== 14. АДАПТИВНОСТЬ ==================== */
@media (max-width: 1080px) {
    .dashboard-grid {
        grid-template-columns: 320px 1fr;
        gap: 16px;
    }
    .highlights-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .analytics-kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .radar-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 860px) {
    .app-layout {
        padding: 16px 16px 40px;
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .popular-cities-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .header-actions {
        width: 100%;
        justify-content: space-between;
    }
    .highlights-grid {
        grid-template-columns: 1fr;
    }
    .analytics-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .hero-temp-value {
        font-size: 52px;
    }
    .hero-stats-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }
}
