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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: #f5f5f5;
    overscroll-behavior-y: none; /* запрет pull-to-refresh на iOS/Android */
}

/* ── Шапка ──────────────────────────────────────────────── */
#header {
    background: linear-gradient(135deg, #2c2c2c 0%, #1a1a1a 100%);
    color: white;
    padding: 6px 14px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
    border-bottom: 2px solid #c0392b;
}

#stats {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    flex-wrap: wrap;
}

#stats span {
    opacity: 0.9;
    white-space: nowrap;
}

#title-btn {
    background: rgba(255,255,255,0.18);
    color: white;
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 999px;
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: default;
    white-space: nowrap;
    letter-spacing: 0.2px;
    height: 40px;
}

/* ── Карта ───────────────────────────────────────────────── */
#map {
    width: 100%;
    height: calc(100vh - 44px);
    position: relative;
}

/* Серо-красная тема: тайлы обесцвечены */
#map .leaflet-tile-pane {
    filter: grayscale(100%) contrast(0.85) brightness(0.95);
}

/* Тонкая красная рамка поверх карты */
#map::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 0 2px rgba(192, 57, 43, 0.25);
    z-index: 500;
}

/* ── Кнопка ИНФО ── */
#info-wrap {
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

#info-btn {
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 999px;
    padding: 8px 20px;
    height: 40px;
    font-size: 14px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
#info-btn:hover { background: rgba(255,255,255,0.28); }
#info-btn.info-btn-active {
    background: rgba(255,255,255,0.35);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

#info-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.18);
    padding: 14px 16px;
    width: 240px;
    animation: calFadeIn 0.15s ease;
    z-index: 9001;
}

.info-section {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}
.info-section:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }

.info-section-title {
    font-size: 12px;
    font-weight: 700;
    color: #c0392b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.info-stat-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #555;
    padding: 2px 0;
}
.info-stat-row span:nth-child(2) { flex: 1; }
.info-stat-row strong { color: #333; font-size: 13px; }
.info-stat-icon { font-size: 14px; flex-shrink: 0; }

.info-legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #555;
    padding: 3px 0;
}

.info-legend-color {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(0,0,0,0.15);
    flex-shrink: 0;
}

.info-dot {
    border-radius: 50%;
    background: #c0392b;
    border: 2px solid rgba(255,255,255,0.6);
    box-shadow: 0 0 0 1.5px rgba(192,57,43,0.5);
    flex-shrink: 0;
}

/* ── Легенда ─────────────────────────────────────────────── */
.legend {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    font-size: 13px;
    line-height: 1.8;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    min-width: 240px;
    max-width: 280px;
}

.legend h4 {
    margin: 0 0 10px 0;
    font-size: 15px;
    color: #333;
    position: sticky;
    top: 0;
    background: white;
    padding: 5px 0;
    z-index: 1;
}

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

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 10px;
    border: 2px solid rgba(0,0,0,0.2);
}

/* ── Список пронумерованных городов ─────────────────────── */
.numbered-cities-list {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #e0e0e0;
}

.numbered-city-item {
    display: flex;
    align-items: center;
    padding: 5px;
    margin: 3px 0;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.numbered-city-item:hover {
    background: #f0f0f0;
}

.city-number-badge {
    min-width: 24px;
    height: 24px;
    background: white;
    color: #c0392b;
    border-radius: 50%;
    border: 2px solid #c0392b;
    box-shadow: 0 1px 4px rgba(192,57,43,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 11px;
    margin-right: 10px;
    flex-shrink: 0;
}

/* ── Скрытие attribution Leaflet + серая полоса ─────────── */
.leaflet-control-attribution {
    display: none !important;
}

#map-attribution-cover {
    position: absolute;
    bottom: 0;
    right: 0;
    z-index: 1000;
    background: rgba(80,80,80,0.82);
    color: rgba(255,255,255,0.55);
    font-size: 10px;
    padding: 2px 8px;
    pointer-events: none;
    user-select: none;
    letter-spacing: 0.2px;
}

/* ── Логотип в шапке ─────────────────────────────────────── */
#header-logo {
    height: 36px;
    width: auto;
    display: block;
    flex-shrink: 0;
    object-fit: contain;
    margin-right: 4px;
}
.city-number-label {
    position: absolute;
    background: white;
    color: #c0392b;
    font-weight: bold;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    border: 2px solid #c0392b;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    pointer-events: none;
    z-index: 1000;
    min-width: 20px;
    text-align: center;
}

/* ── Попап города ────────────────────────────────────────── */
.city-popup {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    min-width: 250px;
}

.city-popup h3 {
    margin: 0 0 12px 0;
    color: #333;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.city-popup p {
    margin: 4px 0;
    font-size: 13px;
    color: #666;
}

.city-popup strong {
    color: #333;
}

.city-note {
    margin-top: 12px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #c0392b;
}

.city-note-title {
    font-weight: bold;
    color: #c0392b;
    margin-bottom: 5px;
    font-size: 12px;
}

.city-note-text {
    font-size: 13px;
    color: #555;
    line-height: 1.5;
}

.popup-actions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Кнопки ──────────────────────────────────────────────── */
.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: #c0392b;
    color: white;
}

.btn-primary:hover {
    background: #a93226;
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.btn-number {
    background: #f39c12;
    color: white;
}

.btn-number:hover {
    background: #e67e22;
}

/* ── Модальное окно ──────────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-content {
    position: relative;
    background: white;
    margin: 10% auto;
    padding: 30px;
    width: 90%;
    max-width: 500px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    animation: slideIn 0.3s;
}

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

.modal-header {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #333;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
    font-size: 14px;
}

.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    min-height: 100px;
    transition: border-color 0.2s;
}

.form-group textarea:focus {
    outline: none;
    border-color: #c0392b;
}

.form-group input[type="number"] {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input[type="number"]:focus {
    outline: none;
    border-color: #c0392b;
}

/* ── Выбор цвета ─────────────────────────────────────────── */
.color-picker {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.color-option {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    border-color: #333;
    transform: scale(1.15);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 25px;
}

.close-modal {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.close-modal:hover {
    color: #333;
}

/* ── Индикаторы ──────────────────────────────────────────── */
.marked-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #ffd700;
    border-radius: 50%;
    margin-left: 5px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

.number-badge-popup {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: white;
    color: #c0392b;
    border: 2px solid #c0392b;
    box-shadow: 0 1px 4px rgba(192,57,43,0.3);
    font-weight: bold;
    font-size: 13px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
}

/* ── Панель текущей даты ─────────────────────────────────── */
/* today-panel теперь встроен в легенду (правый нижний угол) */
#today-panel {
    border-bottom: 2px solid #f0f0f0;
    margin-bottom: 10px;
    padding-bottom: 10px;
}

#today-date {
    font-size: 13px;
    font-weight: 700;
    color: #c0392b;
    text-transform: capitalize;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 8px;
    margin-bottom: 8px;
    line-height: 1.4;
}

.today-empty {
    font-size: 12px;
    color: #aaa;
    text-align: center;
    padding: 6px 0;
}

.today-city-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 13px;
}
.today-city-item:hover { background: #fff5f5; }

.today-time {
    font-size: 12px;
    font-weight: 700;
    color: #c0392b;
    min-width: 36px;
    flex-shrink: 0;
}

.today-num-badge {
    min-width: 22px;
    height: 22px;
    background: white;
    color: #c0392b;
    border-radius: 50%;
    border: 2px solid #c0392b;
    box-shadow: 0 1px 3px rgba(192,57,43,0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 11px;
    flex-shrink: 0;
}

.today-city-name {
    flex: 1;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.today-tags {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

/* ── Поиск в легенде ─────────────────────────────────────── */
.legend-section-title {
    font-size: 14px;
    font-weight: 700;
    color: #333;
    margin: 0 0 8px 0;
    position: sticky;
    top: 0;
    background: white;
    padding: 5px 0 3px;
    z-index: 1;
}

.legend-search-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
    background: #f5f6fa;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 4px 8px;
    transition: border-color 0.2s;
}
.legend-search-wrap:focus-within {
    border-color: #c0392b;
    background: #fff;
}

.legend-search-icon {
    font-size: 13px;
    flex-shrink: 0;
    opacity: 0.5;
}

.legend-search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13px;
    outline: none;
    color: #333;
    min-width: 0;
    font-family: inherit;
}
.legend-search-input::placeholder { color: #bbb; }

.legend-search-clear {
    background: none;
    border: none;
    color: #bbb;
    cursor: pointer;
    font-size: 13px;
    padding: 0 2px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s;
}
.legend-search-clear:hover { color: #e74c3c; }

.legend-no-results {
    font-size: 12px;
    color: #aaa;
    text-align: center;
    padding: 8px 0;
}

#legend-city-list mark {
    background: #fff3b0;
    color: #333;
    border-radius: 2px;
    padding: 0 1px;
}

/* ── Иконки UP / XL в модальном окне ────────────────────── */
.extras-picker {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.extra-icon-option {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    flex-shrink: 0;
}
.extra-icon-option:hover { transform: scale(1.1); border-color: #ccc; }
.extra-icon-option.selected { border-color: #e74c3c; transform: scale(1.1); background: #fff0f0; }
.extra-icon-option img { display: block; pointer-events: none; }

/* ── Пикер даты/времени ──────────────────────────────────── */
.datetime-hint { font-size: 11px; color: #aaa; font-weight: 400; margin-left: 6px; }

.datetime-wheel-row {
    display: flex;
    align-items: center;
    gap: 4px;
    user-select: none;
}

.dt-field-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.dt-arrow {
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
    font-size: 10px;
    line-height: 1;
    padding: 1px 4px;
    transition: color 0.15s;
}
.dt-arrow:hover { color: #c0392b; }

.dt-field {
    min-width: 38px;
    height: 38px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
    outline: none;
    background: #fafafa;
    padding: 0 2px;
    /* убираем нативные стрелки браузера у input[type=number] */
    -moz-appearance: textfield;
    appearance: textfield;
}
.dt-field::-webkit-inner-spin-button,
.dt-field::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.dt-field:hover, .dt-field:focus { border-color: #c0392b; background: #fff5f5; }

.dt-sep { font-size: 18px; font-weight: bold; color: #aaa; margin-bottom: 22px; }
.dt-sep-time { margin: 0 6px 22px; border-left: 2px solid #ddd; height: 24px; }

.datetime-wheel-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.datetime-clear-row {
    width: 100%;
    display: flex;
    justify-content: center;
}

.btn-clear-date {
    width: 34px;
    height: 34px;
    border: 2px solid #c0392b;
    border-radius: 6px;
    background: #fff0f0;
    color: #c0392b;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    padding: 0;
    font-weight: bold;
    margin-bottom: 22px; /* выровнять с dt-field (у которых стрелки сверху/снизу) */
}
.btn-clear-date:hover { background: #c0392b; color: #fff; }

.datetime-clear-row { display: none; } /* убрана отдельная строка */

/* ── Иконки и дата в легенде ─────────────────────────────── */
.legend-city-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.legend-city-name-row { display: flex; align-items: center; gap: 6px; }
.legend-city-name { flex: 1; }
.legend-city-tags { display: flex; align-items: center; gap: 3px; }
.legend-tag-icon { display: block; flex-shrink: 0; }
.legend-city-date { font-size: 11px; color: #888; line-height: 1.3; }

/* ── Кнопка Календарь ────────────────────────────────────── */
#cal-wrap {
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

#cal-btn {
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 999px;
    padding: 8px 20px;
    height: 40px;
    font-size: 14px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
#cal-btn:hover { background: rgba(255,255,255,0.28); }
#cal-btn.cal-btn-active {
    background: rgba(255,255,255,0.35);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ── Панель календаря ────────────────────────────────────── */
#cal-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.18);
    padding: 14px;
    width: 280px;
    flex-direction: column;
    gap: 10px;
    animation: calFadeIn 0.15s ease;
    z-index: 9001;
}

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

#cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

#cal-title {
    font-size: 14px;
    font-weight: 700;
    color: #333;
    text-transform: capitalize;
}

.cal-nav {
    background: none;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 16px;
    color: #c0392b;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    line-height: 1;
}
.cal-nav:hover { background: #fff5f5; border-color: #c0392b; }

#cal-dow {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 4px;
}
#cal-dow span {
    font-size: 11px;
    font-weight: 600;
    color: #aaa;
    text-align: center;
    padding: 2px 0;
}
#cal-dow span:last-child { color: #e74c3c; } /* Вс */

#cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.cal-cell {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    transition: background 0.12s;
    gap: 1px;
}
.cal-cell:hover { background: #fff5f5; }
.cal-empty { cursor: default; pointer-events: none; }

.cal-day-num {
    font-size: 12px;
    font-weight: 500;
    color: #333;
    line-height: 1;
}

.cal-cell.cal-today .cal-day-num {
    background: #c0392b;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.cal-cell.cal-selected {
    background: #fff5f5;
    outline: 2px solid #c0392b;
}

.cal-cell.cal-has-data .cal-day-num { color: #c0392b; font-weight: 700; }

.cal-dot {
    font-size: 9px;
    font-weight: 700;
    background: #c0392b;
    color: white;
    border-radius: 8px;
    padding: 0 4px;
    line-height: 14px;
    min-width: 14px;
    text-align: center;
}

/* ── Список городов по дате ──────────────────────────────── */
#cal-cities-section {
    border-top: 1px solid #f0f0f0;
    padding-top: 10px;
    max-height: 220px;
    overflow-y: auto;
}

#cal-date-label {
    font-size: 12px;
    font-weight: 700;
    color: #c0392b;
    text-transform: capitalize;
    margin-bottom: 6px;
}

.cal-no-cities {
    font-size: 12px;
    color: #aaa;
    text-align: center;
    padding: 6px 0;
}

.cal-city-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s;
    font-size: 12px;
}
.cal-city-item:hover { background: #fff5f5; }

/* ── Панель городов (выпадает из шапки) ─────────────────── */
#cities-panel-wrap {
    position: relative;
}

#title-btn {
    background: rgba(255,255,255,0.18);
    color: white;
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 999px;
    padding: 8px 20px;
    height: 40px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    letter-spacing: 0.2px;
    transition: background 0.15s;
}
#title-btn:hover { background: rgba(255,255,255,0.28); }
#title-btn.cities-btn-active {
    background: rgba(255,255,255,0.35);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

#cities-panel {
    position: fixed;
    top: 54px;
    left: 0;
    width: 580px;
    max-width: 98vw;
    background: white;
    border-radius: 0 0 12px 0;
    box-shadow: 4px 4px 24px rgba(0,0,0,0.18);
    z-index: 9500;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 54px);
    animation: citiesFadeIn 0.18s ease;
}
@keyframes citiesFadeIn {
    from { opacity:0; transform: translateY(-8px); }
    to   { opacity:1; transform: translateY(0); }
}

#cities-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid #333;
    background: linear-gradient(135deg, #2c2c2c 0%, #1a1a1a 100%);
    border-radius: 0 0 0 0;
    border-bottom: 2px solid #c0392b;
}

#cities-search {
    flex: 1;
    border: none;
    background: rgba(255,255,255,0.2);
    color: white;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    outline: none;
    font-family: inherit;
}
#cities-search::placeholder { color: rgba(255,255,255,0.65); }
#cities-search:focus { background: rgba(255,255,255,0.3); }

.cities-panel-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 13px;
    flex-shrink: 0;
    transition: background 0.15s;
}
.cities-panel-close:hover { background: rgba(255,255,255,0.35); }

#cities-panel-list {
    overflow-y: auto;
    flex: 1;
    padding: 4px 0;
    overscroll-behavior: contain; /* список скроллится независимо, без передачи родителю */
}

#cities-panel-footer {
    padding: 8px 14px;
    border-top: 1px solid #eee;
    font-size: 12px;
    color: #888;
    background: #fafafa;
    border-radius: 0 0 12px 0;
    text-align: center;
    flex-shrink: 0;
}
#cities-panel-footer strong {
    color: #c0392b;
}

.cp-city-row {
    display: grid;
    /* №(22) dot(10) name(flex) pop(44) date(96) up(20) xl(20) v(32) c(32) fav(32) extra(28) */
    /* №(22) name(fr) dot(10) pop(44) date(96) up(20) xl(20) v(36) c(36) fav(36) status(28) */
    grid-template-columns: 22px minmax(40px, 1fr) 10px 44px 96px 20px 20px 36px 36px 36px 28px;
    align-items: center;
    gap: 0 6px;
    padding: 5px 10px;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid #f8f8f8;
    font-size: 13px;
}
.cp-city-row:hover { background: #fff5f5; }

.cp-num {
    min-width: 22px;
    height: 22px;
    background: white;
    color: #c0392b;
    border-radius: 50%;
    border: 2px solid #c0392b;
    box-shadow: 0 1px 3px rgba(192,57,43,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 10px;
    flex-shrink: 0;
    margin-right: 4px;
}
.cp-num-empty {
    min-width: 22px;
    height: 22px;
    flex-shrink: 0;
    margin-right: 4px;
}

.cp-type-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1.5px solid rgba(0,0,0,0.15);
    flex-shrink: 0;
    justify-self: center;
}

.cp-name {
    flex: 1;
    font-weight: 500;
    color: #222;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cp-name mark {
    background: #fff3b0;
    color: #333;
    border-radius: 2px;
    padding: 0 1px;
}

.cp-pop {
    font-size: 11px;
    color: #888;
    white-space: nowrap;
    text-align: right;
    background: rgba(0,0,0,0.025);
    border-radius: 4px;
    padding: 1px 3px;
}

.cp-date {
    font-size: 11px;
    color: #c0392b;
    white-space: nowrap;
    text-align: right;
}

.cp-up,
.cp-xl {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.03);
    border-radius: 4px;
    outline: 1px solid rgba(0,0,0,0.07);
    outline-offset: -1px;
}

.cp-tags {
    display: flex;
    align-items: center;
    gap: 2px;
}

.cp-tags-empty {
}

.cp-date-empty {
}

.cp-section-header {
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    background: #fafafa;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    z-index: 2;
}

/* Заголовок секции "ОТМЕЧЕННЫЕ" с иконками справа */
.cp-section-header--marked {
    display: grid;
    /* №(22) name(fr) dot(10) pop(44) date(96) up(20) xl(20) v(36) c(36) fav(36) status(28) */
    grid-template-columns: 22px minmax(40px, 1fr) 10px 44px 96px 20px 20px 36px 36px 36px 28px;
    align-items: center;
    gap: 0 4px;
    padding: 5px 10px;
}

.cp-sh-left {
    grid-column: 1 / 6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Иконки UP / XL — каждая в своей ячейке */
.cp-sh-up,
.cp-sh-xl {
    text-align: center;
    font-size: 11px;
    opacity: 0.65;
    white-space: nowrap;
}

.cp-sh-icons {
    display: contents;
}

.cp-sh-icon {
    text-align: center;
    font-size: 13px;
    line-height: 1;
    cursor: default;
    opacity: 0.75;
}

/* ── Sheet data columns in city rows ────────────────────── */
.cp-sheet-val {
    font-size: 10px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    border-radius: 4px;
    padding: 2px 5px;
    letter-spacing: 0.1px;
    min-width: 36px;
    outline: 1px solid rgba(0,0,0,0.07);
    outline-offset: -1px;
}

.cp-sheet-empty {
}

.cp-status-cell {
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    aspect-ratio: 1;
}
.cp-status-empty {
    background: transparent;
}

.cp-row-numbered {
    background: #fdfcfc;
}
.cp-row-numbered:hover { background: #f5f0f0; }

/* ── Auth Popup Overlay ─────────────────────────────────── */
#auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

#auth-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

#auth-popup {
    position: relative;
    z-index: 1;
    background: white;
    border-radius: 20px;
    padding: 36px 32px 32px;
    width: 340px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    animation: authPopupIn 0.25s cubic-bezier(.34,1.56,.64,1);
}

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

#auth-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

#auth-title {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 6px;
}

#auth-subtitle {
    font-size: 13px;
    color: #888;
    text-align: center;
    margin-bottom: 22px;
    line-height: 1.4;
}

.auth-field {
    width: 100%;
    margin-bottom: 14px;
}

.auth-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.auth-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 15px;
    color: #333;
    outline: none;
    transition: border-color 0.2s;
    background: #fafafa;
}
.auth-input:focus { border-color: #c0392b; background: #fff; }

.auth-error {
    color: #e74c3c;
    font-size: 13px;
    margin-bottom: 10px;
    text-align: center;
    font-weight: 500;
}

#auth-submit {
    width: 100%;
    margin-top: 6px;
    padding: 12px;
    background: linear-gradient(135deg, #c0392b, #a93226);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    letter-spacing: 0.3px;
}
#auth-submit:hover { opacity: 0.9; }
#auth-submit:active { transform: scale(0.98); }
#auth-submit:disabled { opacity: 0.6; cursor: default; }

/* ══════════════════════════════════════════════════════════
   МОБИЛЬНАЯ АДАПТАЦИЯ — @media (max-width: 768px)
   ══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {

    /* ── Шапка ───────────────────────────────────────────── */
    #header {
        padding: 6px 10px;
        position: sticky;
        top: 0;
        z-index: 9000;
    }

    #stats {
        gap: 8px;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    #stats::-webkit-scrollbar { display: none; }

    #title-btn,
    #cal-btn,
    #info-btn {
        padding: 7px 14px;
        font-size: 13px;
        height: 36px;
        flex-shrink: 0;
    }

    /* ── Карта ────────────────────────────────────────────── */
    #map {
        height: calc(100dvh - 50px);
    }

    /* ── Панель ГОРОДА — на мобиле full-screen ────────────── */
    #cities-panel {
        position: fixed;
        top: 50px;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100% !important;
        max-width: 100% !important;
        max-height: calc(100% - 50px) !important;
        border-radius: 0 !important;
        z-index: 99000;
        animation: mobileSlideUp 0.22s ease;
    }

    @keyframes mobileSlideUp {
        from { transform: translateY(100%); opacity: 0; }
        to   { transform: translateY(0);    opacity: 1; }
    }

    #cities-panel-header {
        position: fixed;
        top: 50px;
        left: 0;
        right: 0;
        z-index: 100000;
        padding: 10px 14px;
        border-radius: 0;
    }

    #cities-panel-list {
        margin-top: 58px; /* высота #cities-panel-header на мобиле */
    }

    #cities-search {
        font-size: 16px; /* предотвращает zoom на iOS */
        padding: 8px 12px;
    }

    .cities-panel-close {
        width: 34px;
        height: 34px;
        font-size: 16px;
    }

    /* Строки в списке — крупнее для пальца */
    .cp-city-row,
    .cp-section-header--marked {
        /* Мобиле: 10 колонок без даты, со статусом */
        /* Фиксированные: №(18) dot(8) pop(32) up(16) xl(16) — остальное fr */
        grid-template-columns: 26px minmax(22px, 2.4fr) 8px 32px 16px 16px 1fr 1fr 1fr 0.7fr;
        column-gap: 5px;
    }

    .cp-city-row {
        padding: 9px 12px;
        min-height: 44px;
        font-size: 13px;
    }

    /* Скрываем дату и extra на мобиле */
    .cp-date, .cp-date-empty { display: none; }

    /* Заголовок «ОТМЕЧЕННЫЕ» / «ВСЕ ГОРОДА» — скрываем текст, оставляем только иконки */
    .cp-sh-text { display: none; }
    .cp-section-header { padding: 5px 10px; }
    .cp-sh-left {
        grid-column: 1 / 5; /* №, name, dot, pop — 4 колонки (без даты в мобиле) */
        display: flex;
        align-items: center;
        gap: 3px;
        font-size: 11px;
    }
    /* Заголовок «ВСЕ ГОРОДА» — скрываем текст */
    .cp-sh-plain-text { display: none; }
    .cp-section-header--plain {
        display: flex;
        align-items: center;
        gap: 4px;
        padding: 5px 10px;
    }

    /* Население — чуть компактнее */
    .cp-pop {
        font-size: 10px;
    }

    /* Ячейки статистики из таблицы */
    .cp-sheet-val {
        font-size: 10px;
        padding: 2px 3px;
        min-width: 32px;
    }
    .cp-stats-icon {
        font-size: 12px;
    }

    /* Значок иконки строки иконок — прилипает */
    .cp-stats-icons-row {
        top: 44px; /* высота заголовка панели */
    }

    /* ── Модальное окно — снизу вверх ────────────────────── */
    .modal-content {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        width: 100%;
        max-width: 100%;
        max-height: 92dvh;
        overflow-y: auto;
        border-radius: 20px 20px 0 0;
        padding: 24px 20px 32px;
        animation: modalSlideUp 0.25s ease;
        box-shadow: 0 -8px 40px rgba(0,0,0,0.25);
    }

    @keyframes modalSlideUp {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }

    /* Ручка-индикатор сверху модала */
    .modal-content::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: #ddd;
        border-radius: 2px;
        margin: 0 auto 18px;
    }

    .close-modal {
        right: 18px;
        top: 20px;
        font-size: 26px;
    }

    .modal-header {
        font-size: 18px;
        margin-bottom: 18px;
        padding-right: 30px;
    }

    /* Крупнее поля ввода для пальцев */
    .form-group textarea,
    .form-group input[type="number"] {
        font-size: 16px; /* предотвращает zoom на iOS */
        padding: 12px;
    }

    /* Кнопки в модале */
    .modal-actions {
        flex-direction: row;
        gap: 10px;
    }
    .modal-actions .btn {
        flex: 1;
        padding: 12px;
        font-size: 14px;
    }

    /* Пикер даты чуть компактнее */
    .datetime-hint { display: none; }
    .dt-field {
        min-width: 34px;
        height: 36px;
        font-size: 14px;
    }

    /* ── Панель ИНФО ─────────────────────────────────────── */
    #info-panel {
        position: fixed;
        left: 10px;
        right: 10px;
        top: 58px !important;
        bottom: auto;
        width: auto !important;
        max-height: 70dvh;
        overflow-y: auto;
        border-radius: 16px;
        animation: mobileInfoIn 0.2s ease;
    }

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

    /* ── Панель КАЛЕНДАРЬ ────────────────────────────────── */
    #cal-panel {
        position: fixed;
        left: 8px;
        right: 8px;
        top: 58px !important;
        bottom: auto;
        width: auto !important;
        max-height: 80dvh;
        overflow-y: auto;
        border-radius: 16px;
        animation: mobileInfoIn 0.2s ease;
    }

    #cal-cities-section {
        max-height: 160px;
    }

    /* ── Попап Leaflet ───────────────────────────────────── */
    .leaflet-popup-content-wrapper {
        border-radius: 14px !important;
        max-width: calc(100vw - 40px);
    }
    .leaflet-popup-content {
        margin: 14px !important;
        min-width: unset !important;
        max-width: calc(100vw - 68px);
    }

    .city-popup {
        min-width: unset;
    }

    .city-popup h3 {
        font-size: 16px;
    }

    .city-popup p {
        font-size: 12px;
    }

    /* Кнопки в попапе — покрупнее */
    .popup-actions .btn {
        padding: 8px 12px;
        font-size: 12px;
        min-height: 36px;
    }

    /* ── Контролы Leaflet — смещаем от края ─────────────── */
    .leaflet-top.leaflet-right { right: 6px; }
    .leaflet-bottom.leaflet-right { right: 6px; bottom: 24px; }
    .leaflet-control-zoom a {
        width: 36px !important;
        height: 36px !important;
        line-height: 36px !important;
        font-size: 18px !important;
    }

    /* ── Auth popup ───────────────────────────────────────── */
    #auth-popup {
        width: calc(100vw - 32px);
        max-width: 100%;
        padding: 28px 20px 24px;
    }

    .auth-input {
        font-size: 16px; /* предотвращает zoom на iOS */
    }

    /* ── Легенда (правый угол карты) ─────────────────────── */
    .legend {
        max-width: calc(100vw - 20px);
        max-height: 50dvh;
        min-width: unset;
        font-size: 12px;
    }

    /* Пронумерованный список в легенде — поменьше */
    .numbered-city-item {
        padding: 4px;
    }
    .city-number-badge {
        min-width: 24px;
        height: 24px;
        font-size: 11px;
        margin-right: 7px;
    }
}

/* ── Очень маленькие экраны (≤ 380px) ────────────────────── */
@media (max-width: 380px) {
    #title-btn, #cal-btn, #info-btn {
        padding: 7px 10px;
        font-size: 12px;
    }

    .cp-city-row,
    .cp-section-header--marked {
        /* Фиксированные: №(16) dot(7) pop(28) up(14) xl(14) — остальное fr */
        grid-template-columns: 24px minmax(18px, 2.4fr) 7px 28px 14px 14px 1fr 1fr 1fr 0.7fr;
        column-gap: 3px;
    }
    .cp-sheet-val { font-size: 10px; }
    .cp-stats-icon { font-size: 12px; }

    .modal-content {
        padding: 20px 16px 28px;
    }
}

/* ── Touch-friendly: убираем hover на touch-устройствах ──── */
@media (hover: none) {
    .cp-city-row:hover { background: inherit; }
    .cp-row-numbered:hover { background: #fdfcfc; }
    .numbered-city-item:hover { background: inherit; }
    .today-city-item:hover { background: inherit; }
    .cal-city-item:hover { background: inherit; }
}

