/* ============================================================
   БАЗОВЫЕ СТИЛИ
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    background: #e8ecf1;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* ============================================================
   КОНТЕЙНЕР
   ============================================================ */
.container {
    width: 100%;
    max-width: 2048px;
    height: 100%;
    max-height: 1152px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12);
    padding: 24px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

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

.header h1 {
    color: #1a1a2e;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.header h1 span {
    color: #4a90d9;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #4a5568;
    background: #f0f2f5;
    padding: 8px 18px;
    border-radius: 30px;
    border: 1px solid #e2e8f0;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.online {
    background: #38a169;
    animation: pulse-dot 2s infinite;
}

.status-dot.offline {
    background: #e53e3e;
}

@keyframes pulse-dot {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
    100% { opacity: 1; transform: scale(1); }
}

.last-update {
    font-size: 12px;
    color: #718096;
    margin-left: 4px;
}

/* ============================================================
   КАРТА
   ============================================================ */
.map-wrapper {
    flex: 1;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #f7f9fc;
    min-height: 0;
    border: 1px solid #e2e8f0;
}

.rf-map {
    width: 100%;
    height: 100%;
    position: relative;
}

.rf-map svg {
    width: 100%;
    height: 100%;
    display: block;
}

.rf-map path {
    stroke: #ffffff;
    stroke-width: 1.5;
    stroke-linejoin: round;
    transition: fill 0.25s ease, stroke 0.25s ease;
    cursor: pointer;
}

.rf-map [data-code] {
    fill: #d5dde8;
    transition: fill 0.25s;
}

.rf-map [data-code]:hover {
    fill: #9bb7d9;
    stroke: #4a90d9;
    stroke-width: 2;
}

.rf-map [data-code].active {
    fill: #4a90d9;
    stroke: #2c5282;
    stroke-width: 2.5;
}

.rf-map [data-code].has-votes {
    fill: #b0c9e0;
}

/* ============================================================
   МАРКЕРЫ
   ============================================================ */
.custom-marker {
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.custom-marker.visible {
    animation: marker-appear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes marker-appear {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.marker-dot {
    min-width: 40px;
    min-height: 40px;
    padding: 0 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 700;
    font-size: 16px;
    border: 3px solid #ffffff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.marker-dot.has-votes {
    animation: pulse-marker 2.5s ease-in-out infinite;
}

.marker-dot.level-1 {
    background: linear-gradient(135deg, #fc8181, #e53e3e);
    min-width: 36px;
    min-height: 36px;
    font-size: 14px;
}
.marker-dot.level-2 {
    background: linear-gradient(135deg, #f6ad55, #dd6b20);
    min-width: 40px;
    min-height: 40px;
    font-size: 15px;
}
.marker-dot.level-3 {
    background: linear-gradient(135deg, #f6e05e, #d69e2e);
    min-width: 44px;
    min-height: 44px;
    font-size: 16px;
}
.marker-dot.level-4 {
    background: linear-gradient(135deg, #68d391, #38a169);
    min-width: 48px;
    min-height: 48px;
    font-size: 17px;
}
.marker-dot.level-5 {
    background: linear-gradient(135deg, #63b3ed, #3182ce);
    min-width: 54px;
    min-height: 54px;
    font-size: 19px;
}
.marker-dot.level-6 {
    background: linear-gradient(135deg, #b794f4, #805ad5);
    min-width: 60px;
    min-height: 60px;
    font-size: 21px;
}

@keyframes pulse-marker {
    0% { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15), 0 0 0 0 rgba(74, 144, 217, 0.3); }
    50% { box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2), 0 0 0 12px rgba(74, 144, 217, 0.05); }
    100% { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15), 0 0 0 0 rgba(74, 144, 217, 0.3); }
}

.marker-label {
    background: rgba(255, 255, 255, 0.92);
    color: #1a1a2e;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    margin-top: 6px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

/* ============================================================
   НИЖНЯЯ ПАНЕЛЬ
   ============================================================ */
.bottom-panel {
    display: flex;
    gap: 16px;
    margin-top: 14px;
    flex-shrink: 0;
    align-items: stretch;
}

#info {
    flex: 2;
    padding: 14px 20px;
    border-radius: 10px;
    background: #f7f9fc;
    border: 1px solid #e2e8f0;
    min-height: 56px;
    display: flex;
    align-items: center;
    font-size: 16px;
    color: #2d3748;
}

#info .region-name {
    font-weight: 600;
    color: #cf0f0f;
}

#info .votes-count {
    color: #4a90d9;
    font-weight: 700;
}

#info .highlight-blue {
    color: #4a90d9;
    font-weight: 600;
}

#stats {
    flex: 1;
    min-width: 220px;
    max-height: 200px;
    padding: 14px 18px;
    border-radius: 10px;
    background: #f7f9fc;
    border: 1px solid #e2e8f0;
    overflow-y: auto;
}

#stats::-webkit-scrollbar {
    width: 4px;
}

#stats::-webkit-scrollbar-track {
    background: #edf2f7;
    border-radius: 4px;
}

#stats::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

#stats h3 {
    margin: 0 0 8px 0;
    font-size: 13px;
    color: #4a5568;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

#stats ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#stats li {
    padding: 4px 0;
    border-bottom: 1px solid #edf2f7;
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: #2d3748;
}

#stats li:last-child {
    border-bottom: none;
}

#stats .total-row {
    font-weight: 600;
    border-top: 1px solid #e2e8f0;
    padding-top: 8px;
    margin-top: 4px;
    color: #1a1a2e;
}

#stats .votes-num {
    color: #4a90d9;
    font-weight: 600;
}

/* ============================================================
   ЛЕГЕНДА И СТАТУС
   ============================================================ */
.legend-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    flex-shrink: 0;
}

.legend {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
    padding: 6px 16px;
    background: #f7f9fc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #4a5568;
}

.legend-color {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.status-text {
    text-align: center;
    color: #718096;
    font-size: 12px;
}
.qr {
    width: 15%;
    position: absolute;
}
.qr2 {
    top: 0;
    right: 0;
}
.qr3 {
    bottom: 0;
}
.qr4 {
    bottom: 0;
    right: 0;
}
/* ============================================================
   АДАПТИВНОСТЬ
   ============================================================ */
@media (max-width: 1024px) {
    .container { padding: 16px; }
    .header h1 { font-size: 22px; }
    .bottom-panel { flex-direction: column; }
    #stats { max-height: 150px; }
    .marker-dot { min-width: 32px; min-height: 32px; font-size: 13px; }
    .marker-dot.level-5 { min-width: 44px; min-height: 44px; font-size: 16px; }
    .marker-dot.level-6 { min-width: 50px; min-height: 50px; font-size: 18px; }
}

@media (max-width: 600px) {
    .container { padding: 10px; border-radius: 8px; }
    .header h1 { font-size: 16px; }
    .status-badge { font-size: 11px; padding: 4px 12px; }
    .marker-dot { min-width: 26px; min-height: 26px; font-size: 11px; }
    .marker-label { font-size: 9px; padding: 2px 6px; }
    #info { font-size: 13px; padding: 10px 14px; }
    #stats li { font-size: 12px; }
    .legend { gap: 8px; padding: 4px 12px; }
    .legend-item { font-size: 10px; }
    .legend-color { width: 14px; height: 14px; }
}